:root {
  --bg: #0b0f14;
  --panel: #131a23;
  --panel-2: #182230;
  --line: #24303f;
  --text: #e6edf5;
  --muted: #8b9bb0;
  --accent: #3b82f6;
  --ok: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
}

/* Arabic needs a font stack that actually has Arabic glyphs, and the layout must
   mirror. Getting the font wrong renders tofu boxes, which looks like broken data. */
html[lang="ar"] body { font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif; }
html[dir="rtl"] .top-right { flex-direction: row-reverse; }
html[dir="rtl"] .cols { direction: rtl; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

.top { border-bottom: 1px solid var(--line); background: #0e141b; position: sticky; top: 0; z-index: 5; }
/* Wrap rather than overflow. The header holds the brand plus an API-host input and a
   language button; at 390px those cannot sit on one line, and without wrapping the
   page scrolls horizontally (measured: scrollWidth 421 vs clientWidth 390, caused by
   .top-right's right edge at 421). Keeps the sticky header usable on a phone. */
.top .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 62px; gap: 16px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .mark { color: var(--accent); font-size: 24px; }
.brand strong { display: block; letter-spacing: .2px; }
.brand .sub { color: var(--muted); font-size: 12px; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.apibase { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
/* max-width is what stops the input forcing the row wider than the viewport. */
.apibase input { width: 220px; max-width: 50vw; }
@media (max-width: 560px) {
  /* The API host is an operator affordance, not part of the product flow. Hide it on
     narrow screens rather than letting it dominate the header. */
  .apibase { display: none; }
  .brand .sub { display: none; }
}

.banner { margin: 16px 0 0; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--bad); background: #2a1114; color: #ffd9d9; }
.banner.warn { border-color: var(--warn); background: #2a2311; color: #ffe9c2; }

.cols { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: start; padding: 20px 0 60px; }
@media (max-width: 980px) { .cols { grid-template-columns: 1fr; } }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card h2 { margin: 0 0 14px; font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.card h3 { margin: 20px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font: inherit; font-size: 13px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[readonly] { color: var(--muted); }

.flags { display: flex; flex-wrap: wrap; gap: 8px; }
.flags label { flex-direction: row; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; color: var(--text); font-size: 12px; cursor: pointer; }
.flags input { width: auto; }

table.lines { width: 100%; border-collapse: collapse; font-size: 12px; }
table.lines th { text-align: start; color: var(--muted); font-weight: 500; padding: 4px 6px; }
table.lines td { padding: 3px 4px; }
table.lines input, table.lines select { padding: 5px 6px; }
table.lines td.narrow input { text-align: end; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
button { border-radius: 8px; padding: 9px 14px; font: inherit; font-size: 13px; cursor: pointer; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.secondary { background: #1d2a3a; }
button.ghost { background: transparent; }
.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

.verdict { padding: 11px 13px; border-radius: 8px; font-weight: 600; margin-bottom: 12px; }
.verdict.idle { background: var(--panel-2); color: var(--muted); font-weight: 400; }
.verdict.pass { background: #0f2a1a; color: #b6f0c9; border: 1px solid var(--ok); }
.verdict.fail { background: #2a1114; color: #ffd0d0; border: 1px solid var(--bad); }
.verdict.warnonly { background: #2a2311; color: #ffe9c2; border: 1px solid var(--warn); }

table.kv { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
table.kv td { padding: 4px 0; border-bottom: 1px solid var(--line); }
table.kv td:last-child { text-align: end; font-variant-numeric: tabular-nums; }
table.kv tr.total td { font-weight: 700; border-bottom: none; }

.finding { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; margin-bottom: 6px; font-size: 12.5px; }
.finding.err { border-color: #6b2226; background: #1e1013; }
.finding.warn { border-color: #6b5416; background: #1e1a0f; }
.finding .rule { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--accent); font-size: 11.5px; }
.finding .field { color: var(--muted); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11.5px; }
.finding .msg { display: block; margin-top: 3px; }

details { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
summary { cursor: pointer; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
pre { background: #0a0e13; border: 1px solid var(--line); border-radius: 7px; padding: 10px; overflow: auto; max-height: 340px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11.5px; direction: ltr; text-align: left; }
.missing { color: var(--bad); }
