/* NFSH LAW OS — design system (RTL-first, formal). Fonts: self-host IBM Plex Sans Arabic / Cairo in production
   (CSP allows only 'self'); system fallbacks are used until the font files are added. */
:root {
  --bg: #faf8f3;            /* ivory */
  --surface: #ffffff;
  --surface-2: #f3f0e8;
  --text: #1f2328;          /* charcoal */
  --text-2: #57606a;
  --line: #e2ddd1;
  --accent: #1f4e5f;        /* single restrained accent */
  --accent-ink: #ffffff;
  --danger: #8a1c1c;
  --ok: #1e5e3a;
  --warn: #7a5c00;
  --radius: 6px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --font: "IBM Plex Sans Arabic", "Cairo", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6; }
[dir="ltr"] body { direction: ltr; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-inline-end: 1px solid var(--line); padding: var(--s5) var(--s4); }
.brand { font-weight: 700; font-size: 1.05rem; margin-bottom: var(--s1); }
.brand-sub { color: var(--text-2); font-size: .8rem; margin-bottom: var(--s5); }
.nav a { display: block; padding: var(--s2) var(--s3); border-radius: var(--radius); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface-2); font-weight: 600; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.main { padding: var(--s5) var(--s6); max-width: 1200px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s5); }
h1 { font-size: 1.4rem; margin: 0 0 var(--s4); font-weight: 700; }
h2 { font-size: 1.1rem; margin: var(--s5) 0 var(--s3); }
.muted { color: var(--text-2); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s5); margin-bottom: var(--s4); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: var(--s2) var(--s4); }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
th, td { padding: var(--s2) var(--s3); text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: .9rem; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfbf8; }

.badge { display: inline-block; padding: 0 var(--s2); border-radius: 999px; font-size: .8rem; border: 1px solid var(--line); background: var(--surface-2); }
.badge.ok { color: var(--ok); border-color: #b9d6c3; } .badge.warn { color: var(--warn); border-color: #e3d39c; } .badge.danger { color: var(--danger); border-color: #e2b4b4; }

form .field { margin-bottom: var(--s4); }
label { display: block; font-weight: 600; margin-bottom: var(--s1); font-size: .92rem; }
.hint { color: var(--text-2); font-size: .82rem; margin-top: var(--s1); }
input, select, textarea { width: 100%; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; }
textarea { min-height: 120px; resize: vertical; }
input:disabled, select:disabled { background: var(--surface-2); }
.btn { display: inline-block; padding: var(--s2) var(--s4); border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: var(--s3); align-items: center; }
.alert { padding: var(--s3) var(--s4); border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); margin-bottom: var(--s4); }
.alert.error { border-color: #e2b4b4; color: var(--danger); background: #fbf2f2; }
.alert.success { border-color: #b9d6c3; color: var(--ok); background: #f2f8f4; }

.auth { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.auth .card { width: 100%; max-width: 420px; }
.folder-tree { list-style: none; padding: 0; margin: 0; }
.folder-tree li { padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.folder-tree li.root { font-weight: 700; background: var(--surface-2); }
.empty { padding: var(--s5); text-align: center; color: var(--text-2); }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-inline-end: 0; border-bottom: 1px solid var(--line); padding: var(--s3) var(--s4); }
  .brand-sub { margin-bottom: var(--s2); }
  .nav { display: flex; gap: var(--s1); overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: var(--s1); }
  .nav a { white-space: nowrap; flex: 0 0 auto; padding: var(--s2) var(--s3); }
  .main { padding: var(--s4); min-width: 0; }
  .topbar { flex-wrap: wrap; gap: var(--s2); }
  input, select, textarea { font-size: 16px; }   /* iOS: no zoom-in on focus */
  .grid-2, .kv { grid-template-columns: 1fr; }
}
@media print { .sidebar, .actions { display: none; } .layout { display: block; } }

/* executive dashboard: stat tiles and single-series bar lists (mark color validated against the card surface) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-block-end: 16px; }
.tile { margin: 0; min-inline-size: 0; }
.tile-value { font-size: clamp(1.15rem, 1.8vw, 1.6rem); overflow-wrap: anywhere; font-weight: 700; font-variant-numeric: tabular-nums; margin-block-start: 4px; }
.barlist { margin: 0; }
.barlist figcaption { font-weight: 700; margin-block-end: 8px; }
.barlist ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.barlist li { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; align-items: center; gap: 8px; padding-block: 2px; }
.barlist li:hover { background: rgba(31, 78, 95, .06); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { block-size: 10px; }
.bar-fill { display: block; block-size: 100%; min-inline-size: 2px; background: #1b86a8; border-start-end-radius: 4px; border-end-end-radius: 4px; }
.bar-value { font-variant-numeric: tabular-nums; min-inline-size: 2ch; text-align: end; }
@media (forced-colors: active) { .bar-fill { background: CanvasText; } }

.notifications { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.notifications li { padding-block: 4px; border-block-end: 1px solid var(--line); }

.main { min-width: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap > table { min-width: 100%; }

/* NLME: preserve responsive RTL navigation without widening the page. */
.nlme-sections { display:flex; flex-wrap:wrap; gap:8px; margin-block:12px 16px; min-inline-size:0; max-inline-size:100%; }
.nlme-sections .btn { font-size:.88rem; }
.nlme-panel { min-inline-size:0; overflow-wrap:anywhere; }
.nlme-panel .actions { flex-wrap:wrap; }
.nlme-panel textarea { max-inline-size:100%; }
@media (max-width:860px) {
  .nlme-sections { flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-block-end:8px; }
  .nlme-sections .btn { flex:0 0 auto; white-space:nowrap; }
}

.certificate-body { white-space:pre-wrap; font:inherit; line-height:2; overflow-wrap:anywhere; }
@media print { body:has(.print-target) .main > :not(.print-target) { display:none!important; } body:has(.print-target) .main { padding:0; max-width:none; } .print-target { width:100%; background:white; color:black; border:0; padding:0; } .print-target button, .no-print { display:none!important; } .print-target .table-wrap { overflow:visible; } .print-target table { table-layout:fixed; width:100%; font-size:8pt; } .print-target th, .print-target td { overflow-wrap:anywhere; padding:4px; } tr { break-inside:avoid; } }

@page performance { size:A4 landscape; margin:12mm; }
@media print { body { background:white; } .layout { min-height:0; } .performance-report { page:performance; } .performance-report h2 { font-size:14pt; } .performance-report th:last-child, .performance-report td:last-child { display:none; } }

.judicial-page { display:block; width:100%; max-width:1000px; height:auto; margin:16px auto; border:1px solid var(--line); background:white; }

.judicial-actions { flex-wrap:wrap; }
.judicial-actions > * { max-width:100%; }
.judicial-page { height:auto; }
.kv dd { overflow-wrap:anywhere; }
