/* Meta Origin — مدير التراخيص على الموبايل.
   الألوان من الكتالوج الموحّد (themes.gen.css: data-skin + data-mode، متغيرات بتباين محسوب) والاستايل data-style.
   شكل التطبيق data-look: desktop = زي مدير التراخيص على الكمبيوتر · bank = زي تطبيقات البنوك · ios = بسيط زي آيفون. */
@font-face { font-family: 'Cairo'; src: url('fonts/Cairo-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('fonts/Cairo-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Cairo'; src: url('fonts/Cairo-Bold.ttf') format('truetype'); font-weight: 700 800; font-display: swap; }

:root {
  /* قبل ما الثيم يتحمّل (لوتس البنفسجي — نفس مدير التراخيص) */
  --bg: #f5f5f7; --surface: #ffffff; --surface-2: #fafafa; --border: #ececf1; --text: #1f1f2e; --muted: #6f6f7a;
  --primary: #7c3aed; --primary-text: #7c3aed; --on-primary: #ffffff; --primary-soft: #f3e8ff;
  --danger: #b42318; --warn-bg: #fff4d6; --warn-text: #6b4600; --ok: #157a3c; --info-bg: #e5effa; --info-text: #1d4f8a;
  --font: 'Cairo', system-ui, sans-serif; --radius: 10px;

  --r: calc(var(--radius) + 4px);
  --r-lg: calc(var(--radius) + 10px);
  --ok-bg: color-mix(in srgb, var(--ok) 10%, var(--surface));
  --ok-text: color-mix(in srgb, var(--ok) 80%, var(--text));
  --bad: var(--danger);
  --bad-bg: color-mix(in srgb, var(--danger) 10%, var(--surface));
  --bad-text: color-mix(in srgb, var(--danger) 82%, var(--text));
  /* الهيدر الملوّن: لون الثيم متدرّج — appearance.js بيحسب الطرف التاني (أغمق أو أفتح حسب لون الكلام، تباين ≥ 4.5) */
  --hero: var(--primary);
  --on-hero: var(--on-primary);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 20px rgba(15, 23, 42, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
:root[data-mode="dark"] { --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font); background: var(--bg) var(--bg-image, none) fixed; color: var(--text);
  font-size: 15.5px; line-height: 1.6; overscroll-behavior-y: none; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-text); text-decoration: none; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: ui-monospace, 'SF Mono', Consolas, monospace; letter-spacing: .03em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.ic { width: 20px; height: 20px; flex: none; vertical-align: -4px; }

/* ================= الشريط اللي فوق ================= */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--hero); color: var(--on-hero);
  padding: calc(12px + var(--safe-t)) 18px 14px; display: flex; align-items: center; gap: 12px;
  border-radius: 0 0 22px 22px; box-shadow: 0 8px 24px color-mix(in srgb, var(--primary) 30%, transparent);
}
.top .logo { width: 40px; height: 40px; border-radius: 12px; background: rgba(255, 255, 255, .95); padding: 4px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.top h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 800; line-height: 1.3; }
.top .sub { font-size: 12.5px; opacity: .88; display: block; font-weight: 500; }
.top .tbtn { width: 38px; height: 38px; border-radius: 12px; border: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--on-hero) 18%, transparent); color: inherit; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.dot.ok { background: #22c55e; } .dot.pending { background: #f59e0b; } .dot.bad { background: #ef4444; }

/* ملخص (شكل البنوك) */
.hero-stats { display: none; }
.hello { display: none; }

main { padding: 16px 16px calc(96px + var(--safe-b)); max-width: 640px; margin: 0 auto; animation: rise .22s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ================= شريط التبويبات ================= */
.tabs {
  /* فوق كل حاجة في الصفحة (المحتوى في شكل البنوك طالع فوق الهيدر بـ z-index 6) — وطبقة لوحدها عشان Safari على الآيفون */
  position: fixed; bottom: 0; inset-inline: 0; z-index: 15; transform: translateZ(0); display: flex; gap: 4px; background: var(--surface);
  border-top: 1px solid var(--border); padding: 6px 8px calc(6px + var(--safe-b)); box-shadow: 0 -6px 20px rgba(15, 23, 42, .05);
}
.tabs button {
  flex: 1; border: 0; background: none; padding: 6px 2px; font-size: 11.5px; color: var(--muted); font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 3px; border-radius: 14px; position: relative;
}
.tabs button .ic { width: 23px; height: 23px; }
.tabs button.on { color: var(--primary-text); background: var(--primary-soft); }
.tabs .badge {
  position: absolute; top: 2px; inset-inline-end: calc(50% - 22px); background: #f59e0b; color: #111; border-radius: 9px;
  font-size: 10px; min-width: 17px; height: 17px; line-height: 17px; padding: 0 4px; font-weight: 800;
}

/* ================= الكروت والخانات ================= */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 17px; margin: 0 0 8px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.card h3 { font-size: 15px; margin: 14px 0 6px; font-weight: 700; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.card-title .ti { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }
.card-title h2 { margin: 0; flex: 1; }
label.f { display: block; font-weight: 700; font-size: 13.5px; margin: 14px 0 6px; color: var(--text); }
.in, select.in, textarea.in {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--r); background: var(--surface-2);
  outline: none; min-height: 48px; transition: border-color .15s, box-shadow .15s;
}
.in:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); background: var(--surface); }
.in.bad { border-color: var(--bad); }
.in.good { border-color: var(--ok); }
.row { display: flex; gap: 8px; align-items: stretch; }
.row > .grow { flex: 1; min-width: 0; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.err { color: var(--bad); font-weight: 700; font-size: 14px; margin-top: 8px; }
.err:empty { display: none; }
.okmsg { color: var(--ok); font-weight: 700; font-size: 14px; margin-top: 8px; }

.btn {
  border: 0; border-radius: var(--r); padding: 12px 18px; font-weight: 700; background: var(--primary); color: var(--on-primary);
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--primary) 28%, transparent); transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .5; box-shadow: none; }
.btn.block { width: 100%; margin-top: 14px; }
.btn.light { background: var(--primary-soft); color: var(--primary-text); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--primary-text); border: 1.5px solid var(--border); box-shadow: none; }
.btn.danger { background: var(--bad-bg); color: var(--bad-text); box-shadow: none; }
.btn.green { background: #16a34a; color: #fff; }
.btn.sm { min-height: 38px; padding: 7px 12px; font-size: 13.5px; }
.icon-btn { min-width: 52px; padding: 0 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  border: 1.5px solid var(--border); background: var(--surface-2); border-radius: 999px; padding: 8px 16px; min-height: 42px;
  font-size: 14px; font-weight: 600; color: var(--text);
}
.seg button.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.checks label { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.checks input { width: 20px; height: 20px; accent-color: var(--primary); }

/* ================= البرامج ================= */
.progs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.prog {
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-lg); padding: 16px 10px 14px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 124px; box-shadow: var(--shadow);
}
.prog img, .prog .ph { width: 48px; height: 48px; border-radius: 14px; object-fit: contain; }
.prog .ph, .ph { display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px; }
.prog b { font-size: 14px; line-height: 1.4; }
.prog small { color: var(--muted); font-size: 11.5px; }
.prog.off { opacity: .5; }
.chosen { display: flex; align-items: center; gap: 12px; }
.chosen img, .chosen .ph { width: 42px; height: 42px; border-radius: 12px; }

/* ================= القوايم ================= */
.item { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item > img, .item > .ph { width: 42px; height: 42px; border-radius: 12px; flex: none; object-fit: contain; }
.item .grow { flex: 1; min-width: 0; }
.item b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.item[data-i] { cursor: pointer; }
.tag { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok-text); }
.tag.warn { background: var(--warn-bg); color: var(--warn-text); }
.tag.bad { background: var(--bad-bg); color: var(--bad-text); }
.tag.info { background: var(--info-bg); color: var(--info-text); }
.empty { text-align: center; color: var(--muted); padding: 18px 8px; }
.empty .ic { width: 34px; height: 34px; display: block; margin: 0 auto 6px; opacity: .55; }

/* ================= الترخيص ================= */
.keybox {
  direction: ltr; text-align: left; font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; word-break: break-all;
  background: var(--surface-2); border: 1.5px dashed color-mix(in srgb, var(--primary) 55%, var(--border)); border-radius: var(--r); padding: 12px; user-select: all;
}
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.actions .btn { padding: 10px 6px; font-size: 13.5px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.facts span { color: var(--muted); }

/* ================= النوافذ ================= */
.sheet-bg { position: fixed; inset: 0; background: rgba(2, 6, 23, .5); backdrop-filter: blur(2px); z-index: 40; display: flex; align-items: flex-end; animation: fade .18s ease; }
.sheet {
  background: var(--surface); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 26px 26px 0 0;
  padding: 18px 18px calc(20px + var(--safe-b)); max-height: 92vh; overflow: auto; animation: up .24s cubic-bezier(.2, .8, .2, 1);
}
.sheet h2 { font-size: 18px; margin: 4px 0 10px; font-weight: 800; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: -6px auto 12px; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(96px + var(--safe-b)); z-index: 60; background: #111827; color: #fff;
  border-radius: 14px; padding: 13px 16px; text-align: center; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: up .2s ease;
}

/* ================= الكاميرا ================= */
.cam { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; color: #fff; }
.cam video { flex: 1; width: 100%; object-fit: cover; min-height: 0; }
.cam .frame { position: absolute; inset-inline: 7%; top: 32%; height: 22%; border: 3px solid #fff; border-radius: 18px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .45); pointer-events: none; }
.cam .frame.qr { top: 22%; height: 0; padding-bottom: 86%; inset-inline: 7%; }
.cam .bar { position: absolute; top: calc(10px + var(--safe-t)); inset-inline: 12px; display: flex; gap: 8px; align-items: center; }
.cam .bar .t { flex: 1; font-weight: 700; text-shadow: 0 1px 3px #000; }
.cam .bottom { position: absolute; bottom: 0; inset-inline: 0; padding: 14px 14px calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75) 30%); }
.cam .status { text-align: center; font-weight: 600; min-height: 1.5em; text-shadow: 0 1px 3px #000; }
.cam .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .5); }
.cam .row .btn { flex: 1; }

/* ================= الترحيب والدخول ================= */
.page-hero { background: var(--hero); color: var(--on-hero); padding: calc(34px + var(--safe-t)) 20px 70px; text-align: center; border-radius: 0 0 34px 34px; }
.page-hero img { width: 86px; height: 86px; border-radius: 24px; background: #fff; padding: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, .18); }
.page-hero h1 { font-size: 23px; margin: 14px 0 2px; font-weight: 800; }
.page-hero .muted { color: inherit; opacity: .85; }
.page-body { margin-top: -48px; padding: 0 16px calc(24px + var(--safe-b)); max-width: 520px; margin-inline: auto; }
.hero { text-align: center; padding: 28px 8px 8px; }
.steps { padding-inline-start: 22px; margin: 6px 0; }
.steps li { margin: 7px 0; }
.person { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.person img { width: 58px; height: 58px; border-radius: 50%; object-fit: cover; background: var(--bg); }
.person .grow { flex: 1; }
.phones a { display: inline-block; margin: 3px 6px 0 0; }

/* ================= المظهر ================= */
.looks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.look { border: 2px solid var(--border); border-radius: var(--r); padding: 8px; background: var(--surface-2); text-align: center; font-size: 12.5px; font-weight: 700; }
.look.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.look .mini { height: 74px; border-radius: 10px; background: var(--bg); overflow: hidden; margin-bottom: 6px; position: relative; border: 1px solid var(--border); }
.look .mini i { position: absolute; display: block; border-radius: 5px; }
.swatches { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sw { border: 2px solid var(--border); border-radius: 12px; padding: 6px 4px; background: var(--surface); font-size: 11px; text-align: center; line-height: 1.3; }
.sw.on { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.sw .c { display: flex; height: 22px; border-radius: 7px; overflow: hidden; margin-bottom: 4px; }
.sw .c span { flex: 1; }

/* ================= شكل البنوك (bank) ================= */
:root[data-look="bank"] .top { flex-wrap: wrap; padding-bottom: 66px; border-radius: 0 0 32px 32px; position: relative; }
:root[data-look="bank"] .hello { display: block; width: 100%; font-size: 22px; font-weight: 800; margin-top: 8px; }
:root[data-look="bank"] .hello small { display: block; font-size: 13px; font-weight: 500; opacity: .85; }
:root[data-look="bank"] .hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 12px; }
:root[data-look="bank"] .stat { background: color-mix(in srgb, var(--on-hero) 14%, transparent); border-radius: 18px; padding: 10px 8px; text-align: center; border: 1px solid color-mix(in srgb, var(--on-hero) 22%, transparent); }
:root[data-look="bank"] .stat b { display: block; font-size: 22px; line-height: 1.2; }
:root[data-look="bank"] .stat span { font-size: 11.5px; opacity: .9; }
:root[data-look="bank"] main { margin-top: -50px; position: relative; z-index: 6; }
:root[data-look="bank"] .card, :root[data-look="bank"] .prog { border-radius: 24px; border-color: transparent; box-shadow: 0 10px 30px rgba(15, 23, 42, .08); }
:root[data-look="bank"] .tabs { margin: 0 12px calc(10px + var(--safe-b)); inset-inline: 0; bottom: 0; border-radius: 24px; border: 1px solid var(--border); padding: 6px; box-shadow: 0 10px 30px rgba(15, 23, 42, .14); }
:root[data-look="bank"] main { padding-bottom: calc(110px + var(--safe-b)); }

/* ================= البسيط زي آيفون (ios) ================= */
:root[data-look="ios"] .top {
  background: color-mix(in srgb, var(--bg) 82%, transparent); color: var(--text); box-shadow: none; border-radius: 0;
  backdrop-filter: saturate(1.8) blur(18px); -webkit-backdrop-filter: saturate(1.8) blur(18px); border-bottom: 1px solid var(--border);
}
:root[data-look="ios"] .top .logo { width: 32px; height: 32px; border-radius: 9px; box-shadow: none; border: 1px solid var(--border); }
:root[data-look="ios"] .top .tbtn { background: var(--surface); color: var(--primary-text); border: 1px solid var(--border); }
:root[data-look="ios"] .dot { box-shadow: none; }
:root[data-look="ios"] .page-title { display: block; }
:root[data-look="ios"] .card, :root[data-look="ios"] .prog { border: 0; box-shadow: none; border-radius: 14px; }
:root[data-look="ios"] .btn { box-shadow: none; border-radius: 12px; }
:root[data-look="ios"] .tabs {
  background: color-mix(in srgb, var(--surface) 80%, transparent); backdrop-filter: saturate(1.8) blur(18px); -webkit-backdrop-filter: saturate(1.8) blur(18px); box-shadow: none;
}
:root[data-look="ios"] .tabs button.on { background: none; }
:root[data-look="ios"] .page-hero { background: none; color: var(--text); }
:root[data-look="ios"] .page-hero img { box-shadow: 0 6px 18px rgba(0, 0, 0, .1); border: 1px solid var(--border); }
:root[data-look="ios"] .page-body { margin-top: 0; }
.page-title { display: none; font-size: 30px; font-weight: 800; margin: 2px 4px 12px; letter-spacing: -.01em; }
