:root {
  --bg: #f4f6fa; --card: #fff; --text: #1b2330; --muted: #667085; --line: #e3e7ef;
  --primary: #1a56db; --green: #0f9d58; --red: #d92d20; --orange: #f79009;
  --radius: 16px; --shadow: 0 4px 18px rgba(16, 24, 40, .10);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", Tahoma, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.4;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
.ar { font-family: "Noto Sans Arabic", Tahoma, "Segoe UI", sans-serif; direction: rtl; }
.muted { color: var(--muted); font-size: .9em; }
.small { font-size: .82em; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

label { display: block; font-weight: 600; font-size: .9em; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
.code-input { text-transform: uppercase; letter-spacing: .25em; font-weight: 700; text-align: center; font-size: 1.3em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; border: 0; border-radius: 12px; padding: 12px 18px; cursor: pointer;
  background: #eef2f8; color: var(--text); text-decoration: none; user-select: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn.big { padding: 16px 20px; font-size: 1.1em; }
.btn.sm { padding: 8px 12px; font-size: .88em; border-radius: 10px; }
.btn.ghost { background: transparent; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: #aaa; display: inline-block; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(15, 157, 88, .2); }
.dot.off { background: var(--red); }

.error { color: var(--red); font-weight: 600; min-height: 1.2em; }

.toast-wrap { position: fixed; left: 0; right: 0; top: calc(10px + env(safe-area-inset-top)); z-index: 3000; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 10px; }
.toast { pointer-events: auto; background: #1b2330; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow); max-width: 520px; width: 100%; animation: drop .25s ease; }
.toast.red { background: var(--red); }
.toast.orange { background: #b54708; }
.toast.green { background: var(--green); }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }

.modal-back { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 2000; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: up .2s ease; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 20px; } }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
