/* FaceID dashboards (client + operator). Self-hosted, no external assets. */
:root {
  --bg: #f5f6f9; --surface: #ffffff; --surface-2: #f0f2f6; --text: #111827; --text-2: #4b5565; --muted: #6b7484;
  --line: #e2e6ec; --grid: #eceff3; --brand: #2a78d6; --brand-ink: #ffffff;
  --series-1: #2a78d6; --good: #0ca30c; --good-text: #006300; --critical: #d03b3b; --warning: #fab219; --neutral: #9aa3af;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05); --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --bg: #0d1117; --surface: #161b22; --surface-2: #1c222b; --text: #e8ebf0; --text-2: #b6bec9; --muted: #8b95a3;
    --line: #2a313c; --grid: #232a33; --brand: #3987e5; --brand-ink: #071226;
    --series-1: #3987e5; --good: #0ca30c; --good-text: #4ade80; --critical: #e05252; --neutral: #5b6472;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; }
a { color: var(--brand); }
button, input, select { font: inherit; color: inherit; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, var(--line)); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input[type=text], input[type=password], select { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }

/* shell */
.app { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; padding: 4px 10px 16px; }
.brand small { font-weight: 600; color: var(--muted); font-size: 12px; }
.navbtn { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; border: 0; background: none; padding: 9px 10px;
  border-radius: 8px; color: var(--text-2); font-weight: 600; cursor: pointer; }
.navbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.navbtn:hover { background: var(--surface-2); color: var(--text); }
.navbtn[aria-current="page"] { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); }
.side .grow { flex: 1; }
.side .who { font-size: 12px; color: var(--muted); padding: 8px 10px; border-top: 1px solid var(--line); margin-top: 8px; }
main { padding: 22px 28px 48px; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { font-size: 22px; margin: 0; }
.top .sp { flex: 1; }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { flex-direction: row; flex-wrap: wrap; border-inline-end: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .brand { padding: 4px 8px; width: 100%; } .side .grow, .side .who { display: none; }
  .navbtn { width: auto; } main { padding: 16px; }
}

/* cards, KPIs */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .two { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; margin: 0 0 2px; } .card .sub { color: var(--muted); font-size: 12px; margin: 0 0 12px; }
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 750; letter-spacing: -.01em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .note { color: var(--text-2); font-size: 12px; }

/* charts */
.chart { position: relative; direction: ltr; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + g .bar, .chart .col:hover .bar { filter: brightness(1.12); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); white-space: nowrap; z-index: 5; display: none; color: var(--text); }
.tip b { display: block; margin-bottom: 2px; }
.tip .row { display: flex; gap: 8px; align-items: center; } .tip .row i { width: 8px; height: 8px; border-radius: 2px; }
.tip .row .v { margin-inline-start: auto; font-variant-numeric: tabular-nums; font-weight: 700; }
details.data { margin-top: 8px; font-size: 12px; } details.data summary { cursor: pointer; color: var(--muted); }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.hbar .item { display: grid; grid-template-columns: minmax(110px, 40%) minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.hbar .name { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 10px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
[dir=rtl] .hbar .fill { border-radius: 4px 0 0 4px; margin-inline-start: 0; }
.hbar .val { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; font-size: 13px; }

/* tables */
.tablewrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: start; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700;
  padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.status svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.status.passed { color: var(--good-text); background: color-mix(in srgb, var(--good) 14%, transparent); }
.status.failed, .status.error, .status.disabled { color: var(--critical); background: color-mix(in srgb, var(--critical) 13%, transparent); }
.status.pending, .status.expired, .status.processing { color: var(--text-2); background: var(--surface-2); }
.status.active { color: var(--good-text); background: color-mix(in srgb, var(--good) 14%, transparent); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; } .chip { font-size: 11px; background: var(--surface-2); border-radius: 6px; padding: 1px 7px; color: var(--text-2); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.seg button[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); }

/* drawer + modal */
.drawer { position: fixed; inset: 0 0 0 auto; width: min(560px, 100vw); background: var(--surface); border-inline-start: 1px solid var(--line);
  box-shadow: -10px 0 40px rgba(0,0,0,.15); padding: 20px; overflow-y: auto; transform: translateX(105%); transition: transform .2s; z-index: 20; }
[dir=rtl] .drawer { inset: 0 auto 0 0; transform: translateX(-105%); }
.drawer.open { transform: none; }
.drawer pre { background: var(--surface-2); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: 12px; direction: ltr; text-align: left; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.notice { border: 1px solid color-mix(in srgb, var(--warning) 60%, var(--line)); background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.secret { display: flex; gap: 8px; align-items: center; } .secret code { flex: 1; background: var(--surface-2); padding: 8px 10px; border-radius: 8px; overflow-x: auto; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(420px, 100%); padding: 28px; }
.login h1 { font-size: 22px; margin: 6px 0 4px; } .login p { color: var(--muted); margin: 0 0 18px; }
.login label { display: block; font-weight: 600; margin-bottom: 6px; } .login input { width: 100%; margin-bottom: 14px; }
.err { color: var(--critical); font-weight: 600; min-height: 1.4em; }
.toast { position: fixed; bottom: 20px; inset-inline-start: 50%; transform: translateX(-50%); background: var(--text); color: var(--surface);
  padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 30; display: none; }
pre.code { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 14px; overflow-x: auto; font-size: 12.5px; direction: ltr; text-align: left; margin: 8px 0 0; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ===================== v2 polish ===================== */
:root { --radius: 14px; --brand-soft: color-mix(in srgb, var(--brand) 10%, transparent); }
body { font-size: 14.5px; }
.side { padding: 16px 12px; gap: 2px; }
.org { display: flex; align-items: center; gap: 10px; padding: 10px; margin: 0 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.org .logo { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-weight: 800; flex: none; }
.org b { display: block; font-size: 14px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org small { color: var(--muted); font-size: 11.5px; }
.navsec { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 12px 10px 4px; }
.navbtn { padding: 8px 10px; font-size: 14px; }
.userbox { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); margin-top: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
  background: color-mix(in srgb, var(--brand) 18%, var(--surface)); color: var(--brand); }
.userbox .meta { min-width: 0; flex: 1; } .userbox b { display: block; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox small { color: var(--muted); font-size: 11.5px; }
.iconbtn { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.iconbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main { padding: 26px 32px 56px; }
.top h1 { font-size: 24px; letter-spacing: -.01em; }
.top .desc { color: var(--muted); margin: 2px 0 0; font-size: 13.5px; width: 100%; }
.card { padding: 18px 20px; }
.card-h { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.card-h h2 { font-size: 15px; margin: 0; } .card-h p { color: var(--muted); font-size: 12.5px; margin: 2px 0 0; } .card-h .sp { flex: 1; }

.kpi { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: start; }
.kpi .ic { grid-row: 1 / span 2; grid-column: 2; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); }
.kpi .ic svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kpi .ic.good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good-text); }
.kpi .value { font-size: 30px; }
.kpi .spark { grid-column: 1 / -1; height: 34px; margin-top: 6px; direction: ltr; }
.kpi .spark path.line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.kpi .spark path.area { fill: color-mix(in srgb, var(--series-1) 12%, transparent); stroke: none; }

table.t th { background: transparent; border-bottom: 1px solid var(--line); }
table.t td { padding: 11px 10px; }
.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--surface-2); display: block; }
.thumb.ph { display: grid; place-items: center; color: var(--muted); }
.thumb.ph svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.role { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.role.owner { background: color-mix(in srgb, #7c3aed 14%, transparent); color: #7c3aed; }
.role.admin { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .role.owner { color: #b9a4f5; } }

.persons-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.pcard { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); cursor: pointer; transition: border-color .15s, transform .15s; }
.pcard:hover { border-color: var(--brand); transform: translateY(-1px); }
.pcard .img { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.pcard .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .img svg { width: 34px; height: 34px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.pcard .body { padding: 10px 12px; } .pcard b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard small { color: var(--muted); font-size: 12px; }

/* modal */
dialog.modal { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text);
  box-shadow: 0 24px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(10, 14, 22, .45); }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 16px; flex: 1; }
.modal .mb { padding: 18px 20px; display: grid; gap: 12px; max-height: 70vh; overflow-y: auto; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.field input, .field select { width: 100%; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.perms { display: grid; gap: 6px; }
.perm { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: start; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.perm:has(input:checked) { border-color: color-mix(in srgb, var(--brand) 55%, var(--line)); background: var(--brand-soft); }
.perm input { margin-top: 3px; } .perm b { font-size: 13px; } .perm small { grid-column: 2; color: var(--muted); font-size: 12px; }
.perm.sensitive b::after { content: " •"; color: var(--critical); }
.matrix td.yes { color: var(--good-text); font-weight: 700; text-align: center; } .matrix td.no { color: var(--neutral); text-align: center; }
.matrix th { text-align: center; } .matrix th:first-child, .matrix td:first-child { text-align: start; }

.tabs2 { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs2 button { border: 0; background: none; padding: 9px 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs2 button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.switch { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.switch .tx { flex: 1; } .switch b { display: block; } .switch small { color: var(--muted); }
.switch input { width: 42px; height: 24px; appearance: none; border-radius: 999px; background: var(--neutral); position: relative; cursor: pointer; flex: none; transition: background .15s; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--good); }
.switch input:checked::after { transform: translateX(18px); }
[dir=rtl] .switch input:checked::after { transform: translateX(-18px); }
.login .card { width: min(440px, 100%); padding: 32px; border-radius: 18px; }
.login .pwrules { color: var(--muted); font-size: 12px; margin: -6px 0 12px; }
.banner { display: flex; gap: 10px; align-items: center; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px;
  background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); }
.locked { color: var(--muted); text-align: center; padding: 40px 10px; }

/* v2 layout fixes */
.app { grid-template-columns: 250px minmax(0, 1fr); }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
@media (max-width: 860px) { .app { grid-template-columns: minmax(0, 1fr); } }

/* document details: section headings inside the drawer */
.drawer h3.sec { font-size: 13px; margin: 18px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--text-2); text-transform: none; }
.drawer table.t td, .drawer table.t th { padding: 5px 8px; }

/* brand name in the page language */
html[lang="ar"] .brand-en, html:not([lang="ar"]) .brand-ar { display: none; }
