/* Free tools site. Mobile-first (works at 360px), RTL by default, light + dark. */
:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1b1f24;
  --muted: #5b636e;
  --line: #e1e4e8;
  --accent: #0b6e4f;
  --accent-soft: #e3f3ec;
  --wa: #1f8f4e;
  --crit: #b42318;
  --high: #c4320a;
  --med: #a15c07;
  --warn: #5b636e;
  --ok: #0b6e4f;
  --radius: 14px;
  --font: "Segoe UI", Tahoma, "Geeza Pro", "Noto Sans Arabic", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121417;
    --card: #1b1e22;
    --text: #eceef0;
    --muted: #a3abb5;
    --line: #2c3036;
    --accent: #4cc79a;
    --accent-soft: #17332a;
    --crit: #ff8a80;
    --high: #ffab70;
    --med: #f2c46d;
    --warn: #a3abb5;
    --ok: #4cc79a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.7; }
html[lang="ar"] [lang="en"]:not(html) { display: none !important; }
html[lang="en"] [lang="ar"]:not(html) { display: none !important; }

.wrap { max-width: 880px; margin: 0 auto; padding: 16px; }
header.top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
header.top a.home { color: var(--text); text-decoration: none; font-weight: 700; }
.lang-toggle, .btn { font: inherit; cursor: pointer; border-radius: 10px; }
.lang-toggle { border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 4px 12px; }

h1 { font-size: 1.6rem; line-height: 1.35; margin: 12px 0 8px; }
h2 { font-size: 1.2rem; margin: 0 0 8px; }
h3 { font-size: 1.05rem; margin: 12px 0 4px; }
p.lead { color: var(--muted); font-size: 1.05rem; margin-top: 0; }
.badge { display: inline-block; background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 12px; font-size: .85rem; }
.trust { border-inline-start: 4px solid var(--accent); background: var(--accent-soft); padding: 10px 14px; border-radius: 10px; margin: 12px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.two { grid-template-columns: 1fr 1fr; } }
.card a.more { font-weight: 600; color: var(--accent); }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .85rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 10px 16px; text-decoration: none; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; font-weight: 600; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

label.file { display: block; margin: 10px 0; }
label.file span.name { font-weight: 600; display: block; }
input[type="file"] { max-width: 100%; font: inherit; }
select { font: inherit; max-width: 100%; padding: 4px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.status { min-height: 1.5em; color: var(--muted); }
.error { color: var(--crit); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: start; vertical-align: top; }
th { background: var(--bg); position: sticky; top: 0; }
td.num, .ltr { direction: ltr; unicode-bidi: isolate; }
.map-table td:first-child { white-space: nowrap; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.tile b { display: block; font-size: 1.4rem; }
.sev { font-weight: 700; white-space: nowrap; }
.sev-4 { color: var(--crit); } .sev-3 { color: var(--high); } .sev-2 { color: var(--med); } .sev-1 { color: var(--warn); }
.st-ok { color: var(--ok); font-weight: 600; } .st-review { color: var(--high); font-weight: 600; }
ol.fix { margin: 4px 0; padding-inline-start: 20px; }

video#cam { width: 100%; max-height: 360px; background: #000; border-radius: 10px; }
.cta-box { background: var(--card); border: 2px solid var(--accent); border-radius: var(--radius); padding: 16px; margin: 20px 0; }
footer { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 12px; }

[hidden] { display: none !important; }

/* Narrow screens: tables become stacked cards; each cell shows its column label. */
@media (max-width: 640px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; padding: 6px 10px; }
  table.stack td { border: 0; padding: 3px 0; }
  table.stack td::before { display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
  html[lang="ar"] table.stack td::before { content: attr(data-label-ar); }
  html[lang="en"] table.stack td::before { content: attr(data-label-en); }
  table.stack td.num { direction: inherit; text-align: start; }
}
