:root {
  --bg: #f7f6f2;
  --card: #ffffff;
  --ink: #1c1b18;
  --muted: #6f6c64;
  --line: #e4e1d8;
  --accent: #0e5a4a;
  --accent-soft: #e3efea;
  --bad: #a3271f;
  --bad-soft: #fbe4e1;
  --good: #1d6b35;
  --good-soft: #dff1e3;
  --ui: "IBM Plex Sans Arabic", system-ui, sans-serif;
  --text: "Noto Naskh Arabic", "IBM Plex Sans Arabic", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161614; --card: #1f1f1c; --ink: #ecebe6; --muted: #9c998f; --line: #34332e;
    --accent: #5fbf9f; --accent-soft: #1f3a32; --bad: #f08a80; --bad-soft: #4a2321;
    --good: #7ed39a; --good-soft: #1f3a27;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.7 var(--ui); }
main { max-width: 1080px; margin: 0 auto; padding: 8px 20px 64px; }
a { color: inherit; }

header.top { border-bottom: 1px solid var(--line); background: var(--card); }
header.top .bar { max-width: 1080px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 28px; height: 56px; }
.brand { font-weight: 600; font-size: 18px; text-decoration: none; }
.brand span { color: var(--accent); }
nav { display: flex; gap: 4px; }
nav a { text-decoration: none; padding: 6px 12px; border-radius: 6px; color: var(--muted); }
nav a.on { color: var(--ink); background: var(--bg); font-weight: 500; }

h1 { font-size: 24px; font-weight: 600; margin: 28px 0 2px; }
.sub { color: var(--muted); margin: 0 0 22px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 7px 16px; border-radius: 7px; cursor: pointer; text-decoration: none; display: inline-block;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; padding: 2px 6px; color: var(--muted); }
button.link:hover { color: var(--bad); }

input[type=text], select, textarea {
  font: inherit; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--bg); color: var(--ink);
}
textarea { font-family: var(--text); font-size: 17px; line-height: 1.9; min-height: 420px; resize: vertical; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; padding: 3px; margin-bottom: 18px; background: var(--bg); }
.seg button { border: 0; background: none; padding: 5px 14px; border-radius: 6px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px #0001; font-weight: 500; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .split { grid-template-columns: 1fr; } }

.drop {
  border: 1.5px dashed var(--line); border-radius: 8px; min-height: 420px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 16px; color: var(--muted);
  cursor: pointer; position: relative; background: var(--bg);
}
.drop:hover { border-color: var(--accent); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop img { max-width: 100%; max-height: 360px; border-radius: 4px; }
.drop .file { color: var(--ink); font-weight: 500; }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.msg { font-size: 14px; }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--good); }

details.group { border-top: 1px solid var(--line); }
details.group:first-of-type { border-top: 0; }
details.group > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 2px; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::before { content: "‹"; color: var(--muted); transition: transform .15s; display: inline-block; width: 10px; }
details.group[open] > summary::before { transform: rotate(-90deg); }
.grow { flex: 1; }
.rows { padding: 0 22px 10px 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-top: 1px dashed var(--line); }
.row:first-child { border-top: 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: right; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }

.big { font-size: 64px; font-weight: 600; line-height: 1.1; letter-spacing: -1px; color: var(--accent); }
.meter { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.pct { min-width: 64px; text-align: left; font-weight: 600; }
.case-line { display: flex; align-items: center; gap: 14px; padding: 10px 6px; border-bottom: 1px solid var(--line); text-decoration: none; }
.case-line:hover { background: var(--bg); }
.case-line .meter { width: 160px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.tag.err { color: var(--bad); background: var(--bad-soft); border-color: transparent; }

.doc { font-family: var(--text); font-size: 19px; line-height: 2.1; white-space: pre-wrap; }
.doc del { background: var(--bad-soft); color: var(--bad); text-decoration: line-through; text-decoration-thickness: 1px; border-radius: 3px; padding: 0 2px; }
.doc ins { background: var(--good-soft); color: var(--good); text-decoration: none; border-radius: 3px; padding: 0 2px; }
.page-img { width: 100%; border: 1px solid var(--line); border-radius: 6px; display: block; background: #fff; }
.sticky { position: sticky; top: 16px; align-self: start; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.legend del, .legend ins { font-family: var(--text); }

dialog { border: 0; border-radius: 12px; padding: 0; width: min(1100px, 94vw); max-height: 90vh; background: var(--card); color: var(--ink); }
dialog::backdrop { background: #0006; }
dialog .head { display: flex; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); }
dialog .body { padding: 20px; overflow: auto; max-height: calc(90vh - 60px); }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }
