/* IntegriQ 2.0 — design system */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e3e8ef;
  --line-strong: #cfd7e3;
  --ink: #0b1b33;
  --ink-2: #33445e;
  --muted: #6a7a91;
  --accent: #0b74de;
  --accent-ink: #ffffff;
  --accent-soft: #e6f1fd;
  --accent-2: #0ea5a4;
  --nav: #08172c;
  --nav-2: #0f2442;
  --nav-ink: #c6d3e6;
  --nav-muted: #6f86a6;
  --ok: #12805c;     --ok-soft: #e4f5ed;
  --warn: #b56a00;   --warn-soft: #fdf1dc;
  --bad: #c42d3a;    --bad-soft: #fde8ea;
  --info: #2459c9;   --info-soft: #e7eefc;
  --violet: #6b46c1; --violet-soft: #efe9fb;
  --gray-soft: #edf0f4;
  --shadow: 0 1px 2px rgba(11, 27, 51, .05), 0 4px 16px rgba(11, 27, 51, .05);
  --shadow-lg: 0 20px 50px rgba(11, 27, 51, .18);
  --r: 14px;
  --r-sm: 9px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] { --dark: 1; }
}
:root[data-theme="dark"], :root[data-theme="auto"][data-sys="dark"] {
  --bg: #0b1220;
  --surface: #121b2c;
  --surface-2: #172236;
  --line: #233149;
  --line-strong: #2f4060;
  --ink: #e8eef8;
  --ink-2: #c3cfe1;
  --muted: #8797b0;
  --accent: #3b95f0;
  --accent-soft: #15304f;
  --nav: #070e1a;
  --nav-2: #0e1a2e;
  --ok: #3fbf8f;   --ok-soft: #12352b;
  --warn: #f0a640; --warn-soft: #3a2b12;
  --bad: #f06572;  --bad-soft: #3d1a20;
  --info: #7aa2ff; --info-soft: #18264a;
  --violet: #a98bf0; --violet-soft: #271d44;
  --gray-soft: #1c273b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, .tabnum { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; vertical-align: middle; }
svg.i-sm { width: 15px; height: 15px; }
svg.i-lg { width: 22px; height: 22px; }
[dir="rtl"] svg.flip { transform: scaleX(-1); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex-shrink: 0; background: var(--nav); color: var(--nav-ink);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(59, 149, 240, .16), transparent 60%),
                    linear-gradient(180deg, var(--nav-2), var(--nav) 40%);
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; color: #fff; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #38bdf8, #0b74de); box-shadow: 0 6px 18px rgba(11, 116, 222, .45);
}
.brand-mark svg { width: 21px; height: 21px; color: #fff; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--nav-muted); display: block; line-height: 1.45; margin-top: 2px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; scrollbar-width: thin; scrollbar-color: #233a5c transparent; }
.nav-group { margin-bottom: 8px; }
.nav-head {
  width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: 0;
  color: var(--nav-muted); font-size: 11.5px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase;
  padding: 10px 10px 6px; cursor: pointer;
}
.nav-head svg { width: 14px; height: 14px; transition: transform .2s; }
.nav-group.closed .nav-head svg { transform: rotate(-90deg); }
[dir="rtl"] .nav-group.closed .nav-head svg { transform: rotate(90deg); }
.nav-group.closed .nav-items { display: none; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--nav-ink);
  font-weight: 500; position: relative; margin: 1px 0; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(59, 149, 240, .16); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: #38bdf8;
}
[dir="rtl"] .nav-item.active::before { border-radius: 3px 0 0 3px; }
.nav-item .badge-count {
  margin-inline-start: auto; background: #f59e0b; color: #1b1300; font-size: 11px; font-weight: 700;
  border-radius: 20px; padding: 0 7px; line-height: 18px;
}
.nav-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .06); font-size: 11.5px; color: var(--nav-muted); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar .menu-btn { display: none; }
.search-global { position: relative; flex: 1; max-width: 460px; }
.search-global input { width: 100%; padding: 9px 14px; padding-inline-start: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); }
.search-global > svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results {
  position: absolute; top: calc(100% + 6px); inset-inline: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 420px; overflow: auto; z-index: 60; padding: 6px;
}
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.search-results a:hover, .search-results a.on { background: var(--accent-soft); }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--gray-soft); }
.icon-btn .dot { position: absolute; top: 6px; inset-inline-end: 6px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.lang-btn { font-weight: 600; font-size: 13px; padding: 0 12px; width: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 12px; cursor: pointer; border: 0; background: none; }
.user-chip:hover { background: var(--gray-soft); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  color: #fff; background: linear-gradient(135deg, #0b74de, #0ea5a4); flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11.5px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.avatar.xl { width: 84px; height: 84px; font-size: 26px; border-radius: 20px; }
img.avatar { object-fit: cover; background: var(--gray-soft); display: block; }
.user-chip .who { text-align: start; line-height: 1.2; }
.user-chip .who b { display: block; font-size: 13.5px; }
.user-chip .who span { font-size: 11.5px; color: var(--muted); }

.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; margin: 0 auto; }

/* ---------- dropdown ---------- */
.dropdown {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; min-width: 240px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 70;
}
.dropdown a, .dropdown button.dd {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 11px; border-radius: 8px; color: var(--ink);
  background: none; border: 0; cursor: pointer; text-align: start;
}
.dropdown a:hover, .dropdown button.dd:hover { background: var(--gray-soft); }
.dropdown hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.notif-panel { width: 360px; max-height: 480px; overflow: auto; padding: 0; }
.notif-panel .head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; }
.notif { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.notif:hover { background: var(--surface-2); }
.notif .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.crumb { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; margin-bottom: 4px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 600;
  font-size: 13.5px; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 12px rgba(11, 116, 222, .25); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-soft); }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.icon { padding: 7px; width: 34px; height: 34px; }
.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.btn-group button { border: 0; background: var(--surface); padding: 8px 11px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.btn-group button.on { background: var(--accent-soft); color: var(--accent); }

/* ---------- cards & kpis ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); gap: 10px; }
.card-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.card-body { padding: 18px 20px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; gap: 14px; align-items: flex-start; cursor: default; position: relative; overflow: hidden; text-align: start;
}
button.kpi { cursor: pointer; font: inherit; color: inherit; }
button.kpi:hover, .kpi.on { border-color: var(--accent); }
.kpis.wide { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.kpi .ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .val { font-size: 26px; font-weight: 700; line-height: 1.15; letter-spacing: -.5px; }
.kpi .meta { font-size: 12px; margin-top: 2px; }
.tone-blue { background: var(--info-soft); color: var(--info); }
.tone-green { background: var(--ok-soft); color: var(--ok); }
.tone-amber { background: var(--warn-soft); color: var(--warn); }
.tone-red { background: var(--bad-soft); color: var(--bad); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-teal { background: color-mix(in srgb, var(--accent-2) 14%, transparent); color: var(--accent-2); }
.tone-gray { background: var(--gray-soft); color: var(--ink-2); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600;
  white-space: nowrap; line-height: 20px;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.tag { display: inline-block; background: var(--gray-soft); color: var(--ink-2); border-radius: 6px; padding: 1px 8px; font-size: 12px; margin: 2px; }
.ref { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; color: var(--accent); direction: ltr; unicode-bidi: isolate; font-weight: 600; }

/* ---------- toolbar & filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.input, .select, textarea.input {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 10px; padding: 9px 12px; min-height: 40px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea.input { min-height: 92px; resize: vertical; }
.select { appearance: none; padding-inline-end: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236a7a91' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
[dir="rtl"] .select { background-position: left 10px center; }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.toolbar .search input { padding-inline-start: 36px; }
.toolbar .search svg { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .select { width: auto; min-width: 140px; max-width: 200px; }
.chip-filter { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 20px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-size: 13px; }
.chip-filter.on { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: start; font-size: 12px; font-weight: 600; color: var(--muted); padding: 11px 14px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .title-cell { font-weight: 600; max-width: 380px; }
.tbl .title-cell .ref { display: block; font-weight: 600; margin-bottom: 1px; }
.tbl td.actions { white-space: nowrap; text-align: end; }
.overdue-flag { color: var(--bad); font-weight: 600; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--line); gap: 10px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 4px; }
.pager button { min-width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.pager button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.progress { height: 7px; background: var(--gray-soft); border-radius: 6px; overflow: hidden; min-width: 70px; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.score { font-weight: 700; }
.score.good { color: var(--ok); } .score.mid { color: var(--warn); } .score.low { color: var(--bad); }

/* ---------- record cards ---------- */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding: 16px; }
.rec-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: flex; flex-direction: column;
  gap: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; position: relative;
}
.rec-card:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.rec-card .stripe { position: absolute; inset-inline-start: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 0 3px 3px 0; }
[dir="rtl"] .rec-card .stripe { border-radius: 3px 0 0 3px; }
.rec-card h4 { margin: 0; font-size: 15.5px; line-height: 1.4; }
.rec-card .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; font-size: 13px; color: var(--ink-2); }
.rec-card .facts span { display: flex; gap: 6px; align-items: center; min-width: 0; }
.rec-card .facts span > em { font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-card .facts svg { color: var(--muted); width: 15px; height: 15px; }
.rec-card .foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 11px; margin-top: auto; font-size: 12.5px; }
.mini-stats { display: flex; gap: 14px; }
.mini-stats b { font-size: 15px; display: block; line-height: 1.2; }
.mini-stats span { color: var(--muted); font-size: 11.5px; }

/* ---------- empty / loading ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .ic { width: 60px; height: 60px; border-radius: 18px; background: var(--gray-soft); display: grid; place-items: center; margin: 0 auto 14px; color: var(--muted); }
.empty h4 { color: var(--ink); margin: 0 0 4px; font-size: 16px; }
.skeleton { background: linear-gradient(90deg, var(--gray-soft) 25%, var(--surface-2) 50%, var(--gray-soft) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: grid; place-items: center; min-height: 50vh; }

/* ---------- modal & drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(6, 14, 28, .55); backdrop-filter: blur(2px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 860px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .18s ease-out; }
.modal.sm { max-width: 480px; }
.modal.md { max-width: 640px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); gap: 12px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 18px 18px; }
.drawer-overlay { justify-content: flex-end; padding: 0; align-items: stretch; }
.drawer { background: var(--bg); width: min(980px, 100%); height: 100vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .22s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
[dir="rtl"] .drawer { animation-name: slide-rtl; }
@keyframes slide-rtl { from { transform: translateX(-40px); opacity: .4; } }
.drawer-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 18px 24px 0; }
.drawer-head h2 { margin: 4px 0 8px; font-size: 20px; line-height: 1.35; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 40px; }
.tabs { display: flex; gap: 2px; overflow-x: auto; margin-top: 12px; }
.tabs button { background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .count { background: var(--gray-soft); border-radius: 10px; padding: 0 7px; font-size: 11.5px; color: var(--ink-2); }

/* ---------- forms ---------- */
.form-sec { margin-bottom: 20px; }
.form-sec h4 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.form-sec h4::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fgrid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field label .req { color: var(--bad); }
.field .err { color: var(--bad); font-size: 12px; margin-top: 4px; }
.field.has-err .input, .field.has-err .select { border-color: var(--bad); }
.field .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 22px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; inset-inline-start: 3px; transition: .2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }
[dir="rtl"] .switch input:checked + span::after { transform: translateX(-18px); }

/* ---------- detail view ---------- */
.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.dl > div { padding: 11px 0; border-bottom: 1px dashed var(--line); padding-inline-end: 14px; min-width: 0; }
.dl > div.full { grid-column: 1 / -1; }
.dl dt { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 2px; }
.dl dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.sec-title { font-size: 13px; font-weight: 700; color: var(--ink-2); margin: 22px 0 6px; display: flex; gap: 8px; align-items: center; }
.sec-title:first-child { margin-top: 0; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 0 4px; }
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ""; position: absolute; inset-inline-start: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.tl-item .when { font-size: 12px; color: var(--muted); }
.comment { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.comment .body { white-space: pre-wrap; margin-top: 2px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--surface); }
.file-ic { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; flex-shrink: 0; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: 14px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; background: var(--surface); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.sub-table input, .sub-table select { min-height: 34px; padding: 5px 9px; font-size: 13px; }
.risk-matrix { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; max-width: 250px; }
.risk-matrix div { aspect-ratio: 1; border-radius: 5px; display: grid; place-items: center; font-size: 11px; font-weight: 700; color: rgba(0, 0, 0, .55); }
.risk-matrix div.on { outline: 3px solid var(--ink); outline-offset: -1px; color: #000; }

/* ---------- calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 10px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cal-day { min-height: 118px; border-inline-end: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; cursor: pointer; transition: background .1s; min-width: 0; }
.cal-day:nth-child(7n) { border-inline-end: 0; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { background: var(--surface-2); }
.cal-day.out .d { color: var(--muted); opacity: .6; }
.cal-day .d { font-size: 12.5px; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.cal-day.today .d { background: var(--accent); color: #fff; }
.cal-ev { display: block; font-size: 11.5px; font-weight: 600; padding: 3px 7px; border-radius: 6px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-inline-start: 3px solid; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art {
  background: radial-gradient(90% 70% at 20% 10%, rgba(56, 189, 248, .28), transparent 60%), linear-gradient(160deg, #0d2a4f, #061224 70%);
  color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.auth-art svg.route { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; pointer-events: none; }
.auth-art h2 { font-size: 34px; line-height: 1.25; margin: 0 0 14px; max-width: 460px; position: relative; }
.auth-art p { color: #a9bdd8; max-width: 440px; position: relative; }
.auth-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; position: relative; max-width: 480px; }
.auth-feats div { display: flex; gap: 10px; align-items: center; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-box { width: 100%; max-width: 420px; }
.auth-box h1 { font-size: 26px; margin: 0 0 6px; }
.auth-box .lead { color: var(--muted); margin: 0 0 26px; }
.auth-box .field { margin-bottom: 16px; }
.auth-top { position: absolute; top: 18px; inset-inline-end: 22px; display: flex; gap: 6px; }
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.alert.err { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- toast ---------- */
.toasts { position: fixed; bottom: 22px; inset-inline-end: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; min-width: 260px; max-width: 420px; animation: pop .2s; font-weight: 500; }
.toast.ok svg { color: #4ade80; } .toast.err svg { color: #f87171; }

/* ---------- settings / perms ---------- */
.side-tabs { display: flex; flex-direction: column; gap: 2px; padding: 10px; }
.side-tabs button { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 0; background: none; cursor: pointer; text-align: start; font-weight: 500; color: var(--ink-2); }
.side-tabs button:hover { background: var(--gray-soft); }
.side-tabs button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.split { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.perm-tbl td, .perm-tbl th { text-align: center; }
.perm-tbl td:first-child, .perm-tbl th:first-child { text-align: start; }
.help-art { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--surface); }
.help-art summary { padding: 14px 16px; cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.help-art summary::-webkit-details-marker { display: none; }
.help-art[open] summary { border-bottom: 1px solid var(--line); }
.help-art .ans { padding: 14px 16px; color: var(--ink-2); }
.steps { display: flex; gap: 0; margin-bottom: 22px; }
.steps div { flex: 1; display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--muted); }
.steps div b { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gray-soft); flex-shrink: 0; }
.steps div.on { color: var(--accent); } .steps div.on b { background: var(--accent); color: #fff; }
.steps div.done b { background: var(--ok); color: #fff; }
.steps div:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--line); margin: 0 10px; }
.chart-box { position: relative; height: 270px; }
.chart-box.tall { height: 320px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.date-chip { width: 46px; text-align: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); padding: 4px 0; flex-shrink: 0; line-height: 1.15; }
.date-chip b { display: block; font-size: 17px; }
.date-chip span { font-size: 11px; font-weight: 600; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1024px) {
  .sidebar { position: fixed; inset-inline-start: 0; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(6, 14, 28, .5); z-index: 35; }
  .topbar .menu-btn { display: grid; }
  .split { grid-template-columns: 1fr; }
  .side-tabs { flex-direction: row; overflow-x: auto; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 760px) {
  .content { padding: 18px 16px 50px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .search-global { display: none; }
  .user-chip .who { display: none; }
  .g2, .g3, .g4, .fgrid, .dl { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  .page-head h1 { font-size: 20px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi .ic { width: 34px; height: 34px; }
  .kpi .val { font-size: 21px; }
  .rec-grid { grid-template-columns: 1fr; padding: 12px; }
  .toolbar .search { max-width: none; min-width: 100%; }
  .toolbar .select { flex: 1; max-width: none; }
  .modal { max-height: 100vh; border-radius: 16px 16px 0 0; }
  .overlay:not(.drawer-overlay) { align-items: flex-end; padding: 0; }
  .drawer-body, .drawer-head { padding-inline: 16px; }
  .cal-day { min-height: 76px; padding: 3px; }
  .cal-ev { font-size: 10px; padding: 1px 4px; }
  .notif-panel { width: calc(100vw - 24px); }
  .steps div span { display: none; }
}
@media print {
  .sidebar, .topbar, .toolbar, .pager, .btn, .tabs { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}

/* mixed Arabic/English text: let each line follow its own content direction */
.cal-ev, .rec-card h4, .title-cell, .drawer-head h2, .list-row .grow > div, .search-results .grow, .notif .grow > div { unicode-bidi: plaintext; }
.tbl td.date-cell { white-space: nowrap; }
