/* Zano.live — واجهة النسخة العامة (بدون Tailwind ولا CDN) */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
    --bg: #0f172a; --card: #1e293b; --inner: #0f172a; --border: #334155; --border-soft: #2c3a50;
    --text: #ffffff; --text2: #cbd5e1; --muted: #94a3b8; --faint: #64748b;
    --track: #0f172a; --grid: #334155;
    --rbg: rgba(23, 37, 84, .6); --rborder: #1e3a8a; --rtext: #dbeafe;
    --good: #22c55e; --warn: #eab308; --bad: #ef4444; --blue: #3b82f6; --orange: #f97316;
}
:root[data-theme="light"] {
    --bg: #eef2f7; --card: #ffffff; --inner: #f1f5f9; --border: #cbd5e1; --border-soft: #e2e8f0;
    --text: #0f172a; --text2: #334155; --muted: #475569; --faint: #64748b;
    --track: #e2e8f0; --grid: #e2e8f0;
    --rbg: #eff6ff; --rborder: #bfdbfe; --rtext: #1e3a8a;
    --good: #16a34a; --warn: #ca8a04; --bad: #dc2626;
}

html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; min-height: 100vh; padding: 16px;
    display: flex; justify-content: center; align-items: center;
    font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.5;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; }
input { font: inherit; }
a { color: inherit; }
p, ul, h1, h2 { margin: 0; }
ul { padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.t-muted { color: var(--muted); } .t-faint { color: var(--faint); } .t-2 { color: var(--text2); }

/* ───────── البطاقة ───────── */
.card {
    position: relative; width: 100%; max-width: 460px; padding: 24px;
    background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .5);
}
.card::before {
    content: ""; position: absolute; top: 0; left: 50%; width: 8rem; height: 4px;
    transform: translateX(-50%); border-radius: 0 0 6px 6px;
    background: linear-gradient(90deg, var(--blue), var(--orange));
}
.inner { background: var(--inner); border: 1px solid var(--border); border-radius: 8px; }

/* ───────── الترويسة ───────── */
.hdr { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.ibtn {
    width: 36px; height: 36px; flex: none; display: grid; place-items: center;
    background: var(--inner); border: 1px solid var(--border); border-radius: 12px; color: var(--muted);
    transition: color .2s;
}
button.ibtn:hover { color: var(--blue); }
.logo { color: var(--orange); }
.titles { text-align: center; min-width: 0; }
.brand { font-size: 1.5rem; font-weight: 700; line-height: 1.2; letter-spacing: .02em; }
.brand span { color: var(--blue); }
.slogan { font-size: 11px; font-weight: 600; color: var(--muted); line-height: 1.3; }
.madeby { margin-top: 2px; font-size: 10px; color: var(--faint); line-height: 1.3; }
.madeby b { font-weight: 700; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.tools { display: flex; align-items: center; gap: 8px; }
.seg { display: inline-flex; overflow: hidden; background: var(--inner); border: 1px solid var(--border); border-radius: 8px; }
.seg button { padding: 4px 10px; font-size: 11px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--blue); color: #fff; }
.mini {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
    font-size: 11px; font-weight: 600; text-decoration: none; color: var(--muted);
    background: var(--inner); border: 1px solid var(--border); border-radius: 8px;
}
.mini:hover { color: var(--blue); }

/* ───────── العدّاد ───────── */
.gauge { display: flex; justify-content: center; margin-bottom: 12px; }
.gauge-wrap { position: relative; width: 200px; height: 200px; }
.gauge-wrap svg { width: 100%; height: 100%; display: block; }
.g-track { stroke: var(--track); }
.gauge-arc { transition: stroke-dasharray .9s cubic-bezier(.2, .8, .2, 1), stroke .4s, opacity .3s; }
.gauge-arc.fast { transition: stroke-dasharray .3s linear, stroke .3s, opacity .3s; }
.gauge-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-bottom: 8px; }
#gauge-value { font-size: 3rem; font-weight: 700; line-height: 1; }
#gauge-unit { height: 16px; margin-top: 4px; font-size: 11px; color: var(--faint); }
#gauge-label { margin-top: 4px; padding: 0 16px; text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); }
.gauge-cap { position: absolute; bottom: 4px; inset-inline: 0; text-align: center; font-size: 11px; color: var(--faint); }

/* ───────── معلومات الاتصال ───────── */
.meta { margin-bottom: 16px; padding: 10px 12px; font-size: 12px; }
.meta-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 3px 0; }
.meta-row > :first-child { color: var(--muted); flex: none; }
.meta-row > :last-child { font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reveal { transition: filter .2s; }
.reveal.blur { filter: blur(5px); }

/* ───────── القياسات ───────── */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { padding: 8px; text-align: center; }
.stat small { display: block; margin-bottom: 4px; font-size: 10px; font-weight: 600; color: var(--muted); }
.stat div { display: flex; justify-content: center; align-items: baseline; gap: 4px; direction: ltr; }
.stat b { font-size: 14px; }
.stat i { font-style: normal; font-size: 10px; color: var(--faint); }
.is-bad { color: var(--bad); }

.chartbox { position: relative; height: 100px; margin-bottom: 16px; padding: 8px; }
.chartbox canvas { display: block; width: 100%; height: 100%; }
.chart-title { position: absolute; top: 8px; inset-inline-end: 12px; font-size: 10px; color: var(--faint); pointer-events: none; }
#live-text { position: absolute; top: 8px; font-size: 10px; font-weight: 700; color: var(--blue); direction: ltr; }
:root[dir="rtl"] #live-text { right: 12px; left: auto; }
:root[dir="ltr"] #live-text { left: 12px; right: auto; }
.chartbox.paused { cursor: pointer; }

.speeds { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.speeds label { display: block; margin-bottom: 4px; font-size: 11px; font-weight: 600; color: var(--text2); }
.field { position: relative; }
.field i { position: absolute; top: 50%; inset-inline-start: 12px; transform: translateY(-50%); font-size: 12px; }
.field input {
    width: 100%; padding: 8px 12px; padding-inline-start: 32px; direction: ltr; text-align: left;
    font-size: 14px; font-weight: 700; color: var(--text);
    background: var(--inner); border: 1px solid var(--border); border-radius: 8px;
}
.c-blue { color: #60a5fa; } .c-orange { color: #fb923c; }

.ready { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 16px; padding: 12px; }
.ready > div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.ready > div + div { border-inline-start: 1px solid var(--border); }
.ready i { font-size: 18px; transition: color .3s, filter .3s; }
.ready span { font-size: 10px; color: var(--muted); }
.ready .st { font-weight: 600; color: var(--faint); }
.lvl-unknown { color: #64748b; }
.lvl-good { color: var(--good); filter: drop-shadow(0 0 5px var(--good)); }
.lvl-warn { color: var(--warn); filter: drop-shadow(0 0 5px var(--warn)); }
.lvl-bad { color: var(--bad); }

/* ───────── الأزرار ───────── */
.btn-primary {
    width: 100%; display: flex; justify-content: center; align-items: center; gap: 8px;
    padding: 12px; font-size: 14px; font-weight: 700; color: #fff; text-decoration: none;
    background: var(--orange); border-radius: 8px; box-shadow: 0 10px 15px -3px rgba(249, 115, 22, .2);
    transition: background .2s;
}
.btn-primary:hover:not(:disabled) { background: #ea580c; }
.btn-primary:disabled { opacity: .6; }
.btn-primary.small { width: auto; display: inline-flex; padding: 8px 14px; font-size: 12px; box-shadow: none; }
.btn-ghost {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 12px; font-weight: 600;
    color: var(--text2); background: var(--inner); border: 1px solid var(--border); border-radius: 8px;
}
.btn-ghost:hover { color: var(--blue); }

.data-note { margin-top: 8px; font-size: 10px; line-height: 1.6; text-align: center; color: var(--faint); }

/* ───────── النتيجة ───────── */
.result { margin-top: 16px; padding: 12px; background: var(--rbg); border: 1px solid var(--rborder); border-radius: 12px; color: var(--rtext); }
#result-summary { margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.result li { display: flex; gap: 8px; font-size: 12px; line-height: 1.6; }
.result li + li { margin-top: 8px; }
.result li > i { margin-top: 4px; flex: none; }
.result li b { display: block; }
.ok { color: var(--good); } .wn { color: var(--warn); } .bd { color: var(--bad); }
#tips-box { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rborder); }
#tips-box > p { margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.share-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rborder); }
#share-msg { font-size: 11px; color: var(--good); }

/* ───────── الدعوة للنسخة الكاملة ───────── */
.promo { margin-top: 16px; padding: 14px; }
.promo-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 700; font-size: 13px; }
.promo-head i { color: var(--blue); }
.promo > p { font-size: 11px; color: var(--muted); line-height: 1.7; }
.promo ul { margin: 10px 0 12px; }
.promo li { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text2); }
.promo li + li { margin-top: 6px; }
.promo li i { width: 16px; text-align: center; color: var(--orange); }

/* ───────── التذييل ───────── */
.foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; }
.socials { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.foot .by { font-size: 11px; font-weight: 600; color: var(--muted); direction: ltr; }
.foot .privacy { margin-top: 8px; font-size: 10px; color: var(--faint); line-height: 1.6; }

/* ───────── النافذة ───────── */
.modal {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(2, 6, 23, .65); backdrop-filter: blur(3px);
}
.panel {
    width: 100%; max-width: 460px; max-height: 90vh; display: flex; flex-direction: column; padding: 20px;
    background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .5);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-head h2 { font-size: 16px; font-weight: 700; }
.panel-head h2 i { margin-inline-end: 8px; color: var(--blue); }
.panel-head button { color: var(--muted); font-size: 20px; }
.panel-head button:hover { color: var(--blue); }
.panel-body { flex: 1; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; color: var(--text2); }
th { padding-bottom: 8px; text-align: start; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
td { padding: 8px 0; text-align: start; direction: ltr; border-bottom: 1px solid var(--border-soft); }
td.empty { text-align: center; color: var(--faint); padding: 24px 0; }
.panel-foot { margin-top: 12px; text-align: center; }

@media (max-width: 380px) {
    .card { padding: 18px; }
    .gauge-wrap { width: 180px; height: 180px; }
    #gauge-value { font-size: 2.6rem; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
