:root {
  --bg: #f3f6f9; --panel: #ffffff; --ink: #122033; --muted: #5b6b7d; --line: #dfe6ee; --soft: #edf2f7;
  --brand: #0c487a; --brand-2: #083a63; --brand-soft: #e3edf7; --accent: #18b3a0; --accent-soft: #e0f5f2; --side: #0f2742; --side-ink: #c3d1e0; --side-active: #1b3c61;
  --warn: #b45309; --warn-soft: #fdf1e3; --bad: #c0392b; --bad-soft: #fbe9e7; --ok: #15803d; --ok-soft: #e6f4ea; --info: #2563eb;
  --radius: 12px; --shadow: 0 1px 2px rgba(15, 39, 66, .06), 0 4px 16px rgba(15, 39, 66, .07);
  --font: "Segoe UI", "Noto Sans Arabic", "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
}
:root[data-theme="dark"] {
  --bg: #0b1420; --panel: #121e2d; --ink: #e3eaf2; --muted: #93a4b7; --line: #22344a; --soft: #172537;
  --brand: #5aa2e6; --brand-2: #86bdf0; --brand-soft: #16314d; --accent: #2cc7b2; --accent-soft: #123a37; --side: #08111d; --side-ink: #a8b8ca; --side-active: #16304d;
  --warn-soft: #3a2a14; --bad-soft: #3b1d19; --ok-soft: #15301f; --shadow: 0 1px 2px rgba(0,0,0,.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1420; --panel: #121e2d; --ink: #e3eaf2; --muted: #93a4b7; --line: #22344a; --soft: #172537;
    --brand: #5aa2e6; --brand-2: #86bdf0; --brand-soft: #16314d; --accent: #2cc7b2; --accent-soft: #123a37; --side: #08111d; --side-ink: #a8b8ca; --side-active: #16304d;
    --warn-soft: #3a2a14; --bad-soft: #3b1d19; --ok-soft: #15301f; --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: left; }

/* ---------- buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--brand); }
.btn svg { width: 17px; height: 17px; flex: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea, .input { border: 1px solid var(--line); background: var(--panel); border-radius: 9px; padding: 9px 12px; outline: none; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

/* ---------- login / setup */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 500px at 100% 0, var(--brand-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 26px; }
.brand-mark { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark .logo { width: 46px; height: 46px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.brand-mark h1 { font-size: 20px; margin: 0; }
.brand-mark p { margin: 0; color: var(--muted); font-size: 13px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.alert { padding: 10px 12px; border-radius: 9px; font-size: 14px; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--brand-soft); color: var(--brand-2); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand-mark { padding: 18px 18px 6px; margin: 0; }
.side .brand-mark h1 { color: #fff; font-size: 17px; }
.side .brand-mark p { color: var(--side-ink); opacity: .7; font-size: 12px; }
.side .brand-mark .logo { width: 38px; height: 38px; font-size: 18px; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.nav .group { font-size: 11.5px; letter-spacing: .3px; opacity: .55; padding: 14px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--side-ink); font-size: 14.5px; }
.nav a:hover { background: var(--side-active); color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset -3px 0 0 var(--accent); }
.nav a span:not(.soon) { flex: 1; min-width: 0; }
.nav a .soon { white-space: nowrap; margin-inline-start: auto; font-size: 10.5px; background: rgba(255,255,255,.08); padding: 1px 7px; border-radius: 20px; opacity: .8; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 22px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top h2 { margin: 0; font-size: 18px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 8px; border-radius: 10px; position: relative; }
.user-chip:hover { background: var(--soft); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-2); display: grid; place-items: center; font-weight: 800; }
.user-chip .who { line-height: 1.2; }
.user-chip .who b { display: block; font-size: 14px; }
.user-chip .who small { color: var(--muted); font-size: 12px; }
.dropdown { position: absolute; top: 48px; inset-inline-end: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); min-width: 210px; padding: 6px; z-index: 20; }
.dropdown button { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.dropdown button:hover { background: var(--soft); }
.content { padding: 22px; max-width: 1280px; width: 100%; }

/* ---------- cards / tables */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat small { color: var(--muted); font-weight: 600; }
.stat b { display: block; font-size: 28px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12.5px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 16px; flex: 1; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { max-width: 280px; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: start; font-size: 12.5px; color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--soft); white-space: nowrap; }
table.t td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--soft); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); white-space: nowrap; }
.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.brand { background: var(--brand-soft); color: var(--brand-2); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.soon-page { padding: 50px 20px; text-align: center; }
.soon-page .ico { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.soon-page h3 { margin: 0 0 6px; }
.list-cards { display: none; }

/* ---------- permission matrix */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; padding: 14px; }
.perm-mod { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.perm-mod h4 { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.perm-mod h4 .btn { margin-inline-start: auto; }
.perm-mod label, .perm-mod .prow { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13.5px; cursor: pointer; }
.perm-mod input { accent-color: var(--brand); width: 16px; height: 16px; }
.perm-mod .ov-grant { color: var(--ok); font-weight: 700; }
.perm-mod .ov-deny { color: var(--bad); font-weight: 700; text-decoration: line-through; }
.tri { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; margin-inline-start: auto; }
.tri button { border: 0; background: none; padding: 1px 7px; font-size: 12px; cursor: pointer; color: var(--muted); }
.tri button.on { background: var(--brand); color: #fff; }
.tri button.on.deny { background: var(--bad); }

/* ---------- modal / drawer / toast */
.overlay { position: fixed; inset: 0; background: rgba(8, 18, 15, .45); z-index: 40; display: flex; justify-content: flex-start; }
.drawer { background: var(--panel); width: 520px; max-width: 100%; height: 100%; overflow-y: auto; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer.wide { width: 900px; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.drawer-head h3 { margin: 0; flex: 1; font-size: 17px; }
.drawer-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; flex: 1; }
.drawer-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; position: sticky; bottom: 0; background: var(--panel); }
.modal-center { align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border-radius: 16px; width: 440px; max-width: 100%; box-shadow: var(--shadow); padding: 22px; }
.modal h3 { margin: 0 0 10px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.secret { font-size: 22px; font-weight: 800; letter-spacing: 1px; background: var(--soft); border-radius: 10px; padding: 10px; text-align: center; direction: ltr; user-select: all; }
.toasts { position: fixed; bottom: 18px; left: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: var(--panel); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; max-width: 340px; animation: slide .2s; }
.toast.bad { background: var(--bad); color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 11px 12px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 12px; }
.recent li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.recent { list-style: none; margin: 0; padding: 0 16px; }
.recent li:last-child { border-bottom: 0; }
.recent time { color: var(--muted); margin-inline-start: auto; font-size: 12.5px; }

/* ---------- phone */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; right: 0; width: 270px; z-index: 50; transform: translateX(100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: -10px 0 30px rgba(0,0,0,.3); }
  .side-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 45; }
  .menu-btn { display: inline-flex; }
  .top { padding: 0 12px; }
  .user-chip .who { display: none; }
  .content { padding: 14px; }
  .grid2 { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat b { font-size: 22px; }
  .hide-sm { display: none; }
  .toolbar .input { max-width: none; flex: 1 1 100%; }
  .drawer { width: 100%; }
  .kv { grid-template-columns: 110px 1fr; }
  .toasts { left: 12px; right: 12px; }
}

/* ---------- phase 2: tasks */
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }
.chip { font-size: 11.5px; padding: 1px 8px; border-radius: 20px; background: color-mix(in srgb, var(--cc) 14%, transparent); color: var(--cc); font-weight: 700; }
.bar { height: 6px; background: var(--soft); border-radius: 6px; overflow: hidden; margin: 6px 0; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.bcol { background: var(--soft); border-radius: var(--radius); padding: 10px; min-height: 160px; border: 2px dashed transparent; transition: border-color .15s; }
.bcol.over { border-color: var(--brand); }
.bcol.final { opacity: .92; }
.bcol-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.bcol-head i { width: 10px; height: 10px; border-radius: 50%; }
.bcol-head b { flex: 1; font-size: 14.5px; }
.bcol-body { display: flex; flex-direction: column; gap: 8px; }
.bempty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 6px; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.04); border-inline-start: 4px solid var(--pc); }
.tcard:hover { border-color: var(--brand); border-inline-start-color: var(--pc); }
.tcard.dragging { opacity: .45; }
.tcard-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.tcard-title { font-weight: 700; margin: 4px 0; line-height: 1.45; }
.tcard-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.due { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--muted); }
.due svg { width: 13px; height: 13px; }
.due.late { color: var(--bad); font-weight: 700; }
.due.soon { color: var(--warn); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.tform { display: flex; flex-direction: column; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 10px; }
.task-head { display: flex; flex-direction: column; gap: 10px; }
.status-steps { display: flex; gap: 6px; flex-wrap: wrap; }
.status-steps .step { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 4px 12px; font-size: 13px; cursor: pointer; font-weight: 600; color: var(--muted); }
.status-steps .step:hover:not(:disabled) { border-color: var(--sc); color: var(--sc); }
.status-steps .step.on { background: var(--sc); border-color: var(--sc); color: #fff; }
.status-steps .step:disabled { cursor: default; }
.progress-line { display: flex; align-items: center; gap: 10px; }
.progress-line .bar { flex: 1; margin: 0; }
.sec-title { font-size: 13px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.members { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.mchip { display: inline-flex; align-items: center; gap: 6px; background: var(--soft); border-radius: 20px; padding: 3px 4px 3px 10px; font-size: 13.5px; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 17px; line-height: 1; padding: 0 4px; }
.x:hover { color: var(--bad); }
.row-actions { display: flex; gap: 10px; justify-content: space-between; }
.member-pick, .weekdays { display: flex; flex-wrap: wrap; gap: 8px 16px; }
ul.plain { margin: 0; padding-inline-start: 18px; }
.checklist { display: flex; flex-direction: column; gap: 4px; }
.citem { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; }
.citem input { width: 18px; height: 18px; accent-color: var(--brand); }
.citem span { flex: 1; }
.citem.done span { text-decoration: line-through; color: var(--muted); }
.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { background: var(--soft); border-radius: 12px; padding: 10px 12px; max-width: 92%; }
.comment.mine { background: var(--brand-soft); align-self: flex-end; }
.chead { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.chead time { color: var(--muted); font-size: 12px; margin-inline-start: auto; }
.cbody { white-space: pre-wrap; margin-top: 4px; }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.file { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.file img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; display: block; }
.ficon { width: 56px; height: 56px; display: grid; place-items: center; font-size: 26px; background: var(--soft); border-radius: 8px; }
.finfo { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.finfo a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline time { color: var(--muted); font-size: 12px; margin-inline-end: 10px; }
.click-card { cursor: pointer; }
.click-card:hover { border-color: var(--brand); }
.click-card.archived { opacity: .6; }
.bell { position: relative; padding: 8px; }
.bell svg { width: 21px; height: 21px; }
.bell-n { position: absolute; top: 2px; inset-inline-end: 0; background: var(--bad); color: #fff; font-size: 11px; font-weight: 800; border-radius: 10px; padding: 0 5px; min-width: 18px; text-align: center; line-height: 17px; }
.notif-panel { width: 360px; max-width: calc(100vw - 24px); max-height: 70vh; overflow-y: auto; inset-inline-end: 0; top: 50px; padding: 0; }
.np-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.np-item { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.np-item:hover { background: var(--soft); }
.np-item.unread { background: var(--brand-soft); }
.np-item.sev-alert .np-title { color: var(--bad); }
.np-item.sev-warn .np-title { color: var(--warn); }
.np-title { font-weight: 700; font-size: 14px; }
.np-body { font-size: 13px; color: var(--muted); margin-top: 2px; }
.np-item time { font-size: 11.5px; color: var(--muted); }
@media (max-width: 860px) {
  .board { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .bcol { scroll-snap-align: start; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .notif-panel { position: fixed; top: 60px; left: 12px; right: 12px; width: auto; }
}

/* ---------- phase 3: customers, activities, plan */
.stars { color: #f59e0b; letter-spacing: -1px; font-size: 13px; }
.stars .off { color: var(--line); }
.plinks { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.plinks a.wa { color: #16a34a; font-size: 12.5px; font-weight: 700; }
.late-txt { color: var(--bad); font-weight: 700; }
tr.inactive td { opacity: .5; }
.bulkbar { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--brand-soft); border-radius: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cust-head { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.ch-main { display: flex; gap: 14px; align-items: flex-start; }
.ch-main h2 { margin: 0 0 4px; font-size: 21px; }
.avatar.lg { width: 54px; height: 54px; font-size: 20px; flex: none; }
.ch-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ch-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.fact { background: var(--soft); border-radius: 10px; padding: 9px 12px; }
.fact small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.fact b { font-size: 14.5px; }
.fact.bad b { color: var(--bad); } .fact.warn b { color: var(--warn); }
.kv.wide { grid-template-columns: 180px 1fr; }
ul.acts { list-style: none; margin: 0; padding: 0; position: relative; }
ul.acts::before { content: ''; position: absolute; top: 6px; bottom: 6px; inset-inline-start: 7px; width: 2px; background: var(--line); }
.act { display: flex; gap: 14px; padding: 0 0 18px; position: relative; }
.act-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--panel); border: 3px solid var(--muted); flex: none; margin-top: 3px; z-index: 1; }
.act-dot.ok { border-color: var(--ok); } .act-dot.bad { border-color: var(--bad); }
.act-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.act-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; width: 100%; }
.act-head time { margin-inline-start: auto; color: var(--muted); font-size: 12.5px; }
.act-notes { white-space: pre-wrap; background: var(--soft); border-radius: 10px; padding: 8px 12px; width: 100%; }
.act-next { font-size: 13.5px; color: var(--brand-2); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.act-next.due { color: var(--bad); font-weight: 700; } .act-next.done { color: var(--muted); text-decoration: line-through; }
.act-tools { display: flex; gap: 6px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 6px 14px; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.pill.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; }
.grid3e { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
details summary { cursor: pointer; color: var(--brand-2); font-weight: 700; }
.plan-sum { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.plan-sum .bar { flex: 1; height: 8px; margin: 0; }
.plan-list { display: flex; flex-direction: column; gap: 10px; }
.pcard { display: flex; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-inline-start: 4px solid var(--tc); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.pcard.final { opacity: .7; box-shadow: none; }
.pc-seq { width: 34px; height: 34px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-weight: 800; flex: none; font-size: 13px; }
.pc-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.pc-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pc-name { font-weight: 800; font-size: 16px; color: var(--ink); }
.pc-result { color: var(--ok); font-size: 13.5px; }
.pc-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; align-items: center; }
.pc-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pick-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.check.pick { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.lists-wrap { display: grid; grid-template-columns: 220px 1fr; gap: 14px; align-items: start; }
.list-side { display: flex; flex-direction: column; padding: 6px; }
.list-side a { padding: 9px 12px; border-radius: 8px; color: var(--ink); }
.list-side a.on { background: var(--brand-soft); color: var(--brand-2); font-weight: 700; }
@media (max-width: 860px) {
  .grid3e { grid-template-columns: 1fr; }
  .lists-wrap { grid-template-columns: 1fr; }
  .list-side { flex-direction: row; overflow-x: auto; }
  .list-side a { white-space: nowrap; }
  .kv.wide { grid-template-columns: 120px 1fr; }
  .ch-actions .btn { flex: 1 1 auto; justify-content: center; }
}
.field input[type=color] { height: 42px; padding: 4px; cursor: pointer; }

/* ---------- phase 4: stock */
.badge.kind-RM { background: #e0f2fe; color: #0369a1; } .badge.kind-PK { background: #f3e8ff; color: #7e22ce; }
.badge.kind-BK { background: #fef3c7; color: #b45309; } .badge.kind-FG { background: var(--ok-soft); color: var(--ok); } .badge.kind-OT { background: var(--soft); color: var(--muted); }
:root[data-theme="dark"] .badge.kind-RM, :root[data-theme="dark"] .badge.kind-PK, :root[data-theme="dark"] .badge.kind-BK { background: var(--soft); }
.line-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.line-row select { flex: 1 1 240px; }
.count-in { max-width: 120px; font-weight: 700; }
.count-table td { padding: 7px 10px; }
tr.total-row td { background: var(--soft); }
@media (max-width: 860px) { .count-in { max-width: 90px; } }

/* ---------- phase 5: sales documents */
.drawer.xwide { width: 1180px; }
.doc-wrap { display: grid; grid-template-columns: 1fr 280px; gap: 18px; align-items: start; }
.doc-wrap > .doc-main:only-child { grid-column: 1 / -1; }
.doc-side { background: var(--soft); border-radius: 12px; padding: 12px; position: sticky; top: 70px; }
.doc-head { display: flex; flex-direction: column; gap: 12px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.ppick { position: relative; }
.ppick-sel { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--brand-soft); border-radius: 9px; }
.ppick-sel b { font-size: 16px; flex: 1; }
.ppick-list { position: absolute; z-index: 5; inset-inline: 0; top: 44px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); max-height: 300px; overflow-y: auto; }
.ppick-list:empty { display: none; }
.doc-lines { display: flex; flex-direction: column; gap: 6px; }
.dl-row { display: grid; grid-template-columns: minmax(220px, 3fr) 110px 90px 110px 70px 120px 28px; gap: 8px; align-items: start; }
.dl-head { font-size: 12.5px; color: var(--muted); font-weight: 700; padding: 0 2px; }
.dl-item { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dl-info { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.dl-total { padding-top: 9px; text-align: end; display: flex; flex-direction: column; gap: 4px; }
.doc-foot { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.doc-totals { background: var(--soft); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.doc-totals .tr { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.doc-totals .tr.grand { border-top: 2px solid var(--ink); padding-top: 6px; margin-top: 4px; font-size: 18px; }
@media (max-width: 1100px) { .doc-wrap { grid-template-columns: 1fr; } .doc-side { position: static; } }
@media (max-width: 860px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
  .dl-head { display: none; }
  .dl-row { grid-template-columns: 1fr 1fr 1fr; background: var(--soft); padding: 10px; border-radius: 10px; }
  .dl-row .dl-item { grid-column: 1 / -1; }
  .dl-row .dl-total { grid-column: 1 / 3; text-align: start; padding-top: 0; }
  .doc-foot { grid-template-columns: 1fr; }
}

/* ---------------- phase 6: purchases & finance */
.rate-banner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--brand-soft); color: var(--brand-2); padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; }
.rate-banner svg { width: 20px; height: 20px; }
.rate-banner b { font-size: 17px; }
.box-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.box-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.box-card:hover { border-color: var(--brand); }
.bc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bc-bal { font-size: 24px; font-weight: 800; text-align: start; }
.bc-bal.neg { color: var(--bad); }
.bc-today { font-size: 13px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--brand); box-shadow: var(--shadow); }
.alloc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kvb { background: var(--soft); border-radius: 9px; padding: 8px 10px; }
.kvb span { display: block; color: var(--muted); font-size: 12px; }
.big-amount { font-size: 30px; font-weight: 800; text-align: start; }
.big-amount small { font-size: 14px; color: var(--muted); font-weight: 600; }
.je-row { display: grid; grid-template-columns: minmax(220px, 2.4fr) 120px 120px 1.4fr 28px; gap: 8px; align-items: start; }
table.tb tr.grp td { background: var(--soft); }
table.tb tr.grp.lvl1 td { font-size: 15px; }
table.t tfoot td { border-top: 2px solid var(--line); background: var(--soft); }
@media (max-width: 760px) {
  .je-row { grid-template-columns: 1fr 1fr; }
  .je-row > :first-child, .je-row > :nth-child(4) { grid-column: 1 / -1; }
  .kv-grid { grid-template-columns: 1fr; }
  .box-grid { grid-template-columns: 1fr; }
}

table.tb .row-edit { opacity: 0; }
table.tb tr:hover .row-edit { opacity: 1; }
@media (hover: none) { table.tb .row-edit { opacity: 1; } }
/* 6.1 */
.cash-row { display: grid; grid-template-columns: minmax(170px, 1.6fr) 1.3fr 110px minmax(90px, auto) 28px; gap: 8px; align-items: center; }
.cash-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stop-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: var(--panel); }
.stop-head { display: flex; align-items: center; gap: 8px; }
.stop-head b { flex: 1; }
.inv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.inv-chips label { border: 1px solid var(--line); border-radius: 20px; padding: 4px 10px; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.inv-chips label.on { background: var(--brand-soft); border-color: var(--brand); }
@media (max-width: 760px) { .cash-row { grid-template-columns: 1fr 1fr; } .cash-row > :first-child { grid-column: 1 / -1; } }
.cont-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; background: var(--brand-soft); color: var(--brand-2); border-radius: 20px; padding: 2px 10px; }
.cont-tag.off { background: var(--soft); color: var(--muted); }
button.cont-tag { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: 12px; padding: 1px 9px; }
button.cont-tag:not(.off) { border-color: var(--brand); font-weight: 600; }
button.cont-tag:disabled { cursor: default; }

/* phase 7: production */
.bm-row { display: grid; grid-template-columns: minmax(200px, 2.6fr) 100px 100px 110px 100px 28px; gap: 8px; align-items: center; }
.bm-row.bm-head, .fl-row.bm-head { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.bm-row.diff input { border-color: var(--warn); }
.fl-row { display: grid; grid-template-columns: minmax(200px, 2.6fr) 110px 100px 1.4fr 28px; gap: 8px; align-items: center; }
.log-add { display: grid; grid-template-columns: 1fr 70px 70px; gap: 6px; }
@media (max-width: 760px) {
  .bm-row, .fl-row { grid-template-columns: 1fr 1fr 1fr; }
  .bm-row > :first-child, .fl-row > :first-child { grid-column: 1 / -1; }
  .bm-row.bm-head, .fl-row.bm-head { display: none; }
}
.grid4 > *, .grid2 > *, .doc-main, .doc-wrap > * { min-width: 0; }
.field input, .field select { max-width: 100%; min-width: 0; }
/* 7.1: price-hidden documents */
@media (min-width: 761px) { .doc-lines.np .dl-row { grid-template-columns: minmax(220px, 3fr) 110px 90px 120px 28px; } }
.doc-lines.np .dl-row > :nth-child(4), .doc-lines.np .dl-row > :nth-child(5) { display: none; }
.doc-totals:empty { display: none; }
.doc-lines.np .dl-head > :nth-child(6) { visibility: hidden; }

/* phase 8: reports & dashboard */
.rep-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; margin-bottom: 8px; }
.rep-card { display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: inherit; text-decoration: none; box-shadow: var(--shadow); }
.rep-card:hover { border-color: var(--brand); }
.rep-card span { color: var(--muted); font-size: 12.5px; }
svg.rchart { width: 100%; height: auto; display: block; }
.rc-bar { fill: var(--brand); } .rc-bar.neg { fill: var(--bad); } .rc-bar.s1 { fill: #d97706; }
.rc-lbl { font-size: 12px; fill: var(--ink); } .rc-val, .rc-ax { font-size: 11px; fill: var(--muted); }
.rc-line { stroke: var(--brand); stroke-width: 2.5; } .rc-dot { fill: var(--brand); } .rc-grid { stroke: var(--line); }
.dash-charts { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 8px; }
.stat.warn-card b { color: var(--warn); }
table.rep-t tr.grp td { background: var(--soft); font-weight: 700; }
table.rep-t tr.grand td { font-size: 15px; border-top: 2px solid var(--line); }
@media (max-width: 900px) { .dash-charts { grid-template-columns: 1fr; } }

/* ---------- 8.2 searchable combo */
.cmb { position: relative; min-width: 0; width: 100%; }
.cmb > input { width: 100%; }
.cmb-list { position: fixed; z-index: 9999; max-height: 280px; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 4px; direction: rtl; }
.cmb-opt { padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1.35; }
.cmb-opt .s { font-size: 12px; color: var(--muted); }
.cmb-opt:hover, .cmb-opt.on { background: var(--soft); }
.cmb-opt.cur { font-weight: 700; }

/* 8.2 payment mode */
.pay-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; padding: 10px 12px; background: var(--soft); border-radius: 10px; }
.pay-bar .field { margin: 0; min-width: 160px; }
.pay-bar .seg button:disabled { cursor: default; }

/* 8.2 trials */
.tl-row { display: grid; grid-template-columns: minmax(180px, 2.4fr) 140px 70px minmax(110px, 1fr) 28px; gap: 8px; align-items: center; }
.tl-row > * { min-width: 0; }
table.cmp tr.diff td:first-child { color: var(--brand); font-weight: 700; }
table.cmp tr.diff { background: var(--brand-soft); }
table.cmp tr.sep td { border-top: 2px solid var(--line); }
@media (max-width: 640px) { .tl-row { grid-template-columns: 1fr 110px 56px; } .tl-row > :nth-child(4) { grid-column: 1 / 3; } }

/* 8.2 brand identity: logo */
.brand-logo { display: block; height: 34px; width: auto; }
.side .brand-mark { flex-direction: column; align-items: flex-start; gap: 4px; }
.side .brand-mark p { margin: 0; }
.login-logo { height: 58px; width: auto; display: block; margin-bottom: 6px; }
.logo-d { display: none; }
:root[data-theme="dark"] .logo-l { display: none; } :root[data-theme="dark"] .logo-d { display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo-l { display: none; } :root:not([data-theme="light"]) .logo-d { display: block; } }

/* 8.3 payroll */
.pr-row { display: grid; grid-template-columns: minmax(150px, 1.6fr) repeat(4, minmax(80px, .8fr)) minmax(90px, 1fr) 110px 32px; gap: 6px; align-items: center; }
.pr-row > * { min-width: 0; }
.pr-row.paid { opacity: .75; }
.pr-row.paid .input { background: var(--soft); }
.pay-totals { display: flex; flex-wrap: wrap; gap: 12px; }
.pay-totals > div { background: var(--soft); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 200px; }
.pay-totals b { font-size: 20px; }
@media (max-width: 760px) { .pr-row { grid-template-columns: 1fr 1fr 1fr; } .pr-row.dl-head { display: none; } .pr-row > :first-child { grid-column: 1 / -1; } }

/* 8.4 chart of accounts tree */
.acc-tree { padding: 6px 0; }
.acc-row { display: grid; grid-template-columns: 22px 78px minmax(140px, 1fr) auto 130px auto; gap: 8px; align-items: center; padding: 5px 12px; border-bottom: 1px solid var(--line); }
.acc-row > * { min-width: 0; }
.acc-row.grp { background: var(--soft); }
.acc-row:hover { background: var(--brand-soft); }
.acc-caret { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 0; }
.acc-code { color: var(--muted); font-size: 12.5px; }
.acc-name { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.acc-tags .badge { font-size: 11px; padding: 1px 6px; }
.acc-bal { font-size: 13px; text-align: left; }
.acc-act { display: flex; gap: 2px; }
.acc-act .btn { padding: 2px 8px; }
@media (max-width: 640px) { .acc-row { grid-template-columns: 20px 60px 1fr auto; } .acc-tags, .acc-bal { display: none; } }

/* 8.4 pricing centre */
.pc-set { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.pc-apply { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 10px; background: var(--brand-soft); border: 1px solid var(--brand); }
.pc-matrix td, .pc-matrix th { vertical-align: top; }
.pc-matrix .pc-prod { min-width: 170px; }
.pc-matrix .pc-kg { max-width: 100px; font-weight: 700; }
.pc-cell { min-width: 118px; }
.pc-price { display: flex; align-items: center; gap: 3px; }
.pc-price .input { max-width: 86px; padding: 4px 6px; }
.pc-price .muted { font-size: 11px; }
.pc-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.pc-sug { display: block; font-size: 11.5px; margin-top: 3px; }
.pc-none { background: var(--soft); }
.input.manual { border-color: var(--warn); background: var(--warn-soft); }
.mg { font-weight: 700; font-size: 12px; padding: 0 5px; border-radius: 6px; }
.mg.ok { color: var(--ok); background: var(--ok-soft); } .mg.warn { color: var(--warn); background: var(--warn-soft); } .mg.bad { color: var(--bad); background: var(--bad-soft); }

/* ---------- v2: sidebar phase badges and version */
.nav a.later { opacity: .6; }
.side-ver { margin-top: auto; padding: 14px 18px; font-size: 11.5px; color: var(--side-ink); opacity: .55; }

/* ---------- v2: permission matrix (sections x actions) */
.pgrid-box { display: flex; flex-direction: column; gap: 10px; }
.plegend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13px; }
.plegend span { display: inline-flex; align-items: center; gap: 5px; }
.plegend i { font-style: normal; pointer-events: none; }
.pgrid-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: auto; }
.pgrid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.pgrid th, .pgrid td { padding: 5px 6px; border-bottom: 1px solid var(--line); text-align: center; vertical-align: middle; }
.pgrid thead th { position: sticky; top: 0; z-index: 2; background: var(--soft); font-size: 12.5px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.pgrid .pmod { position: sticky; right: 0; z-index: 1; background: var(--panel); text-align: right; font-weight: 400; min-width: 150px; }
.pgrid thead .pmod { z-index: 3; background: var(--soft); }
.pgrid .pmod > div { display: flex; align-items: center; gap: 6px; }
.pgrid .pmod .badge { font-size: 10.5px; padding: 0 6px; }
.pgrid .pall { padding: 1px 6px; font-size: 11.5px; margin-top: 2px; }
.pgrid tr.psec td { background: var(--brand-soft); color: var(--brand-2); font-weight: 700; text-align: right; font-size: 12.5px; position: sticky; right: 0; }
.pgrid.cmp .pmod { font-size: 13px; min-width: 210px; max-width: 280px; }
.pgrid.cmp thead th { min-width: 84px; white-space: normal; }
.pc { width: 28px; height: 28px; border-radius: 7px; border: 1.5px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 800; font-size: 15px; line-height: 1; display: inline-grid; place-items: center; padding: 0; color: #fff; }
.pc.on { background: var(--brand); border-color: var(--brand); }
.pc.grant { background: var(--ok); border-color: var(--ok); }
.pc.deny { background: var(--bad); border-color: var(--bad); }
.pc:disabled { cursor: default; opacity: .75; }
.pc:not(:disabled):hover { border-color: var(--brand); }
.pna { color: var(--line); }
.pext { text-align: right !important; min-width: 180px; }
.pext button { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 2px 10px; margin: 2px; font-size: 12px; cursor: pointer; color: var(--muted); }
.pext button.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-2); font-weight: 700; }
.pext button.grant { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.pext button.deny { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); text-decoration: line-through; }
.pext button:disabled { cursor: default; }
.pbar { display: inline-block; width: 90px; height: 6px; border-radius: 4px; background: var(--soft); overflow: hidden; vertical-align: middle; margin-inline-end: 8px; }
.pbar i { display: block; height: 100%; background: var(--brand); }
.drawer.wide .drawer-body { gap: 14px; }

/* ---------- v2: setup steps */
.steps { display: flex; gap: 6px; margin-bottom: 4px; }
.steps span { flex: 1; height: 4px; border-radius: 3px; background: var(--line); }
.steps span.on { background: var(--brand); }
.auth-card.wide { max-width: 520px; }
.drawer-foot { z-index: 5; flex-wrap: wrap; }
td.pbar-cell { white-space: nowrap; }
@media (max-width: 600px) { .pgrid .pmod { min-width: 112px; font-size: 12.5px; } .pc { width: 26px; height: 26px; } }

/* ---------- v2: حركة اليوم */
.act-bar .btn svg { width: 17px; height: 17px; }
.act-card { cursor: pointer; transition: border-color .15s; }
.act-card:hover, .act-card.on { border-color: var(--brand); }
.act-card b { font-size: 24px; }
.act-delta { font-weight: 700; }
.act-delta.up { color: var(--ok); }
.act-delta.down { color: var(--bad); }
.act-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 14px; }
.act-chips button { border: 1px solid var(--line); background: var(--panel); border-radius: 20px; padding: 5px 12px; cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.act-chips button i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); display: inline-block; }
.act-chips button b { color: var(--muted); font-weight: 700; }
.act-chips button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.act-chips button.on b { color: #fff; opacity: .85; }
.act-list { padding: 6px 0; }
.act-hour { position: sticky; top: 0; background: var(--soft); color: var(--muted); font-size: 12.5px; font-weight: 700; padding: 4px 16px; direction: ltr; text-align: right; z-index: 1; }
.act-row { display: grid; grid-template-columns: 46px 34px 1fr auto; gap: 10px; align-items: center; padding: 9px 16px; border-bottom: 1px solid var(--line); border-inline-start: 3px solid var(--c); }
.act-row:last-child { border-bottom: 0; }
.act-row.click { cursor: pointer; }
.act-row.click:hover { background: var(--soft); }
.act-row time { color: var(--muted); font-size: 13px; }
.act-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.act-ico svg { width: 18px; height: 18px; }
.act-main { min-width: 0; }
.act-main > div:first-child { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.act-no { color: var(--muted); font-size: 13px; }
.act-sub { font-size: 13.5px; color: var(--ink); opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-val { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 14px; white-space: nowrap; }
.act-empty { padding: 40px 20px; text-align: center; }
.act-empty .ico { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 12px; }
@media (max-width: 600px) {
  .act-row { grid-template-columns: 34px 1fr auto; padding: 9px 12px; }
  .act-row time { display: none; }
  .act-card b { font-size: 20px; }
}
.act-cards { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }

/* v2 phase 3: bulk grid editor */
.grid-ed { max-height: calc(100vh - 260px); overflow: auto; }
.grid-ed table.t th { position: sticky; top: 0; z-index: 2; background: var(--soft); white-space: nowrap; }
.grid-ed td { padding: 3px 4px; }
.grid-ed .gi { width: 100%; border: 1px solid transparent; background: transparent; color: inherit; font: inherit; font-size: 13px; padding: 5px 6px; border-radius: 6px; }
.grid-ed .gi:hover:not(:disabled) { border-color: var(--line); }
.grid-ed .gi:focus { outline: none; border-color: var(--brand); background: var(--panel); }
.grid-ed .gi:disabled { opacity: .6; cursor: not-allowed; }
.grid-ed td.chg { background: var(--warn-soft); }
.grid-ed td.ro { color: var(--muted); }
.grid-ed tr.new-row td { background: var(--accent-soft); }
.grid-ed tr.inactive td { opacity: .55; }
.grid-ed td:first-child, .grid-ed th:first-child { position: sticky; right: 0; z-index: 1; background: var(--panel); }
.grid-ed th:first-child { z-index: 3; background: var(--soft); }
.grid-ed td.chg:first-child { background: var(--warn-soft); }

/* 2.3.1 calendar */
.cal-bar { flex-wrap: wrap; gap: 8px; align-items: center; }
.cal-title { font-size: 17px; min-width: 150px; }
.cal-views { padding: 0; margin: 0; }
.cal-chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 12px; }
.cal-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--muted); font-size: 13px; }
.cal-chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); opacity: .35; }
.cal-chip.on { color: var(--ink); border-color: var(--c); } .cal-chip.on i { opacity: 1; }
.cal-wrap { padding: 0; overflow: hidden; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); background: var(--soft); text-align: center; border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 108px; padding: 4px; border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-grid.week .cal-cell { min-height: 360px; }
.cal-cell:nth-child(7n) { border-inline-end: 0; }
.cal-cell:hover { background: var(--soft); }
.cal-cell.out { background: var(--bg); } .cal-cell.out .cal-num { opacity: .45; }
.cal-num { font-size: 12.5px; font-weight: 700; padding: 2px 4px; align-self: flex-start; border-radius: 999px; min-width: 24px; text-align: center; }
.cal-cell.today .cal-num { background: var(--brand); color: #fff; }
.cal-item { display: block; width: 100%; text-align: start; border: 0; border-inline-start: 3px solid var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--ink);
  border-radius: 5px; padding: 2px 6px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; font-family: inherit; }
.cal-item.k-event { background: var(--c); color: #fff; }
.cal-item.done, .cal-row.done b { text-decoration: line-through; opacity: .6; }
.cal-t { font-weight: 700; margin-inline-end: 4px; font-variant-numeric: tabular-nums; }
.cal-more { font-size: 11.5px; color: var(--muted); padding: 0 6px; }
.cal-list { display: flex; flex-direction: column; gap: 10px; }
.cal-day { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.cal-day.today { border-color: var(--brand); }
.cal-day-h { display: flex; align-items: center; gap: 8px; }
.cal-row { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-inline-start: 3px solid var(--c); background: var(--soft); border-radius: 8px; cursor: pointer; }
.cal-row .cal-t { min-width: 74px; font-size: 12.5px; color: var(--muted); }
.cal-colors { display: flex; gap: 8px; }
.cal-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.cal-color.on { border-color: var(--ink); box-shadow: 0 0 0 2px var(--panel) inset; }
.cal-people { max-height: 170px; overflow: auto; }
@media (max-width: 760px) { .cal-cell { min-height: 64px; } .cal-item { font-size: 0; height: 6px; padding: 0; } .cal-item.k-event { font-size: 0; } .cal-grid.week .cal-item { font-size: 12px; height: auto; padding: 2px 6px; } .cal-dow { font-size: 11px; padding: 6px 2px; } }

/* 2.3.2 navigation: back button and title crumbs */
.back-btn { padding: 6px 8px; }
.back-btn svg { width: 20px; height: 20px; }
.top h2 .crumb { color: var(--muted); text-decoration: none; font-weight: 600; }
.top h2 .crumb:hover { color: var(--brand, var(--ink)); text-decoration: underline; }
.top h2 .crumb-sep { color: var(--muted); margin: 0 8px; font-weight: 400; }
@media (max-width: 700px) { .top h2 { font-size: 16px; } .top h2 .crumb-sep { margin: 0 4px; } }
/* 2.3.2 paged lists */
.load-more { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px 8px 4px; }

/* 2.3.2 tasks page: sticky bar, quick add, "مهامي" grouped by due date, phone board */
.tk-sticky { position: sticky; top: 60px; z-index: 4; background: var(--bg); margin: -6px -4px 6px; padding: 6px 4px 4px; }
.tk-filters { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.btn.on-filter { border-color: var(--brand); color: var(--brand); }
.tk-projchip { display: flex; align-items: center; gap: 4px; background: color-mix(in srgb, var(--cc) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--cc) 35%, transparent); color: var(--ink); border-radius: 10px; padding: 7px 12px; margin-bottom: 8px; }
.tk-projchip b { color: var(--cc); }
.tk-projchip .x { margin-inline-start: auto; }
.tk-quick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.tk-quick .input { flex: 1; min-width: 220px; border-style: dashed; }
.tk-qdays { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tk-qdays button { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 16px; padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.tk-qdays button.on { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); font-weight: 700; }
.tk-sum { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.tk-sumchip { border: 1px solid color-mix(in srgb, var(--gc) 40%, transparent); background: color-mix(in srgb, var(--gc) 9%, var(--panel)); color: var(--gc); border-radius: 18px; padding: 5px 12px; font: inherit; font-size: 13.5px; cursor: pointer; }
.tk-group { margin-bottom: 14px; scroll-margin-top: 170px; }
.tk-ghead { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; padding: 6px 2px; font: inherit; color: var(--gc); cursor: pointer; text-align: start; border-bottom: 2px solid color-mix(in srgb, var(--gc) 30%, transparent); }
.tk-ghead b { font-size: 15px; }
.tk-caret { display: inline-block; transition: transform .15s; }
.tk-group.folded .tk-caret { transform: rotate(90deg); }
.tk-group.folded .tk-rows { display: none; }
.tk-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tk-row { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-inline-start: 4px solid var(--pc); border-radius: 10px; padding: 9px 12px; cursor: pointer; }
.tk-row:hover { border-color: var(--brand); border-inline-start-color: var(--pc); }
.tk-row.final .tk-title { text-decoration: line-through; color: var(--muted); }
.tk-tick { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--panel); color: transparent; font-size: 13px; font-weight: 800; cursor: pointer; display: grid; place-items: center; padding: 0; }
.tk-tick:hover { border-color: var(--ok); color: var(--ok); }
.tk-tick.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.tk-main { flex: 1; min-width: 0; }
.tk-title { font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.tk-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tk-side { display: flex; align-items: center; gap: 8px; flex: none; }
.board { grid-auto-columns: minmax(170px, 1fr); }
.board.board-phone { display: block; }
.tk-colseg { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 6px; }
.tk-colseg button { flex: none; border: 1px solid var(--line); background: var(--panel); border-radius: 18px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.tk-colseg button.on { border-color: var(--gc); background: color-mix(in srgb, var(--gc) 14%, var(--panel)); font-weight: 700; }
.tk-colseg .n { margin-inline-start: 6px; color: var(--muted); }
.tk-move { margin-inline-start: auto; font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--ink); padding: 2px 4px; }
@media (max-width: 700px) {
  .tk-sticky { position: static; margin: 0; padding: 0; }
  .tk-quick .input { min-width: 0; flex-basis: 100%; }
  .top h2 .crumb-card, .top h2 .crumb-sep:not(.crumb-tab), .top h2 .crumb-tab { display: none; }
  .top h2 .crumb { color: var(--ink); font-weight: 700; }
  .tk-row { padding: 9px 10px; gap: 8px; }
  .tk-meta .num { display: none; }
}

/* 2.4.0 sales: product → pack picker, folded details, the invoice's drums part */
.dl-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dl-pick.one { grid-template-columns: 1fr; }
.det-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: -4px; }
.det-toggle { color: var(--brand-2); font-weight: 600; }
.doc-details { border-inline-start: 3px solid var(--brand-soft); padding-inline-start: 12px; }
.doc-drums { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.doc-drums .dd-head { width: 100%; display: flex; align-items: center; gap: 10px; background: var(--soft); border: 0; padding: 10px 14px; font: inherit; cursor: pointer; text-align: start; color: inherit; }
.doc-drums .dd-head .muted { font-size: 12.5px; flex: 1; }
.doc-drums .dd-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.dd-sec { display: flex; flex-direction: column; gap: 6px; }
.dd-title { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.dd-title .muted { font-size: 12px; }
.dd-row { display: grid; grid-template-columns: minmax(160px, 2fr) 90px 28px; gap: 8px; align-items: center; }
.dd-row.in { grid-template-columns: minmax(160px, 2fr) 90px minmax(120px, 1fr) minmax(160px, 2fr) 28px; }
.dd-sec > .btn { align-self: flex-start; }
@media (max-width: 760px) {
  .dl-pick { grid-template-columns: 1fr; }
  .dd-row, .dd-row.in { grid-template-columns: 1fr 90px 28px; background: var(--soft); padding: 8px; border-radius: 10px; }
  .dd-row.in > :nth-child(3), .dd-row.in > :nth-child(4) { grid-column: 1 / 3; }
  .dd-row.in > .x { grid-row: 1; grid-column: 3; }
}
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.reason-chips .chip { border: 1px solid var(--line); background: var(--soft); color: var(--ink); border-radius: 20px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.reason-chips .chip:hover { border-color: var(--brand); }
.modal textarea.input { resize: vertical; min-height: 70px; }

/* 2.7.0 payroll line editor and attendance */
.ln-grid { display: grid; grid-template-columns: minmax(140px, 1.6fr) minmax(110px, 1fr) minmax(100px, 1fr) auto; gap: 6px 8px; align-items: center; }
.ln-grid > * { min-width: 0; }
.ln-grid .btn.sm { padding: 4px 8px; font-size: 12px; white-space: nowrap; }
.chk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 4px 10px; max-height: 240px; overflow: auto; padding: 8px; background: var(--soft); border-radius: 10px; }
@media (max-width: 760px) { .ln-grid { grid-template-columns: 1fr 1fr; } .ln-grid > :nth-child(4n+1) { grid-column: 1 / -1; padding-top: 6px; } .ln-grid > :nth-child(-n+4) { display: none; } }

/* 2.7.2 KPI board */
.kpi-cards { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.stat.kpi { display: flex; flex-direction: column; gap: 3px; }
.stat.kpi b { font-size: 24px; }
.kpi-row { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: 12px; }
.kpi-d { font-weight: 700; font-size: 12.5px; color: var(--muted); }
.kpi-d.up { color: var(--ok); } .kpi-d.down { color: var(--bad); }
.kpi-spark { width: 100%; height: 34px; margin-top: 4px; }
@media (max-width: 760px) { .kpi-cards { grid-template-columns: 1fr 1fr; gap: 8px; } .stat.kpi { padding: 10px 12px; } .stat.kpi b { font-size: 18px; } .kpi-row .muted { display: none; } .kpi-spark { height: 24px; } }
