:root {
  --bg: #f4f6fa; --card: #fff; --ink: #0f1b2d; --muted: #64748b; --line: #e3e8f0;
  --accent: #10336b; --accent-2: #1c4f9c; --accent-soft: #e8eef8;
  --green: #0f9d6b; --green-soft: #e3f6ee; --orange: #b45309; --orange-soft: #fdf1df;
  --red: #dc2626; --red-soft: #fde8e8; --gray-soft: #eef1f5;
  --radius: 16px; --shadow: 0 1px 2px rgba(15,27,45,.06), 0 4px 16px rgba(15,27,45,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1220; --card: #101c30; --ink: #e8eef7; --muted: #8296b4; --line: #1e2d45;
    --accent: #3b6fd4; --accent-2: #5a8ae6; --accent-soft: #15284a;
    --green: #34c08f; --green-soft: #0e2b22; --orange: #f0a43a; --orange-soft: #2e2210;
    --red: #f26464; --red-soft: #321515; --gray-soft: #17243a; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "IBM Plex Sans Arabic", -apple-system, system-ui, sans-serif; font-size: 16px; line-height: 1.5; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent-2); }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px 40px; }
.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 14px 0 10px;
  padding-top: max(14px, env(safe-area-inset-top)); }
.row { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 40px; border-radius: 10px; }
.brand b { font-size: 18px; }
.brand small { color: var(--muted); display: block; font-size: 13px; line-height: 1.2; }
.spacer { flex: 1; }

.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:active { transform: scale(.97); }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.soft { background: var(--accent-soft); color: var(--accent-2); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.stat b { font-size: 22px; display: block; }
.stat span { color: var(--muted); font-size: 13px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.search { width: 100%; padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card); margin: 6px 0 14px; }
.input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); margin-top: 6px; }
label { display: block; font-size: 14px; color: var(--muted); margin-top: 12px; }

.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 560px) { .cards { grid-template-columns: 1fr; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 2px; font-size: 17px; }
.card .meta { color: var(--muted); font-size: 13px; }
.card .acts { display: flex; gap: 8px; margin-top: 12px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.valid { background: var(--green-soft); color: var(--green); }
.pill.needs_login { background: var(--orange-soft); color: var(--orange); }
.pill.unknown { background: var(--gray-soft); color: var(--muted); }
.pill.running { background: var(--accent-soft); color: var(--accent-2); }

.modal-bg { position: fixed; inset: 0; background: rgba(5,10,20,.55); display: flex; align-items: flex-end;
  justify-content: center; z-index: 50; padding: 0; }
.modal { background: var(--card); border-radius: 20px 20px 0 0; padding: 20px; width: 100%; max-width: 560px;
  padding-bottom: max(20px, env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
@media (min-width: 560px) { .modal-bg { align-items: center; } .modal { border-radius: 20px; } }
.modal h2 { margin: 0 0 4px; }
.err { background: var(--red-soft); color: var(--red); padding: 10px 14px; border-radius: 12px; margin-top: 12px; font-size: 14px; }
.ok { background: var(--green-soft); color: var(--green); padding: 10px 14px; border-radius: 12px; margin-top: 12px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 8px; }
.check { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; background: var(--accent-soft);
  padding: 12px; border-radius: 12px; }
.check input { width: 20px; height: 20px; margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.spin { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--accent-2);
  border-radius: 50%; animation: s 1s linear infinite; margin: 30px auto; }
@keyframes s { to { transform: rotate(360deg); } }
