/* Tarjimli admin — RTL, light & dark */
@font-face { font-family: "Plex"; src: url(/IBMPlexSansArabic-arabic-400.woff2) format("woff2"); font-weight: 400; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/IBMPlexSansArabic-arabic-500.woff2) format("woff2"); font-weight: 500; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/IBMPlexSansArabic-arabic-600.woff2) format("woff2"); font-weight: 600 700; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/IBMPlexSansArabic-latin-400.woff2) format("woff2"); font-weight: 400; unicode-range: U+0000-00FF, U+2000-206F; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/IBMPlexSansArabic-latin-500.woff2) format("woff2"); font-weight: 500; unicode-range: U+0000-00FF, U+2000-206F; font-display: swap; }
@font-face { font-family: "Plex"; src: url(/IBMPlexSansArabic-latin-600.woff2) format("woff2"); font-weight: 600 700; unicode-range: U+0000-00FF, U+2000-206F; font-display: swap; }

:root {
  --bg: #f3f5f4; --surface: #ffffff; --surface-2: #f7f9f8; --line: #e4e9e7; --line-2: #eef2f0;
  --ink: #12211d; --muted: #5d6d69; --hint: #8a9894;
  --brand: #00a884; --brand-ink: #0b6b57; --brand-dark: #075e54; --brand-soft: #e3f5ef;
  --blue: #3b82f6; --violet: #8b5cf6; --amber: #f59e0b; --red: #dc3b3b; --red-soft: #fdecec; --amber-soft: #fff4dc;
  --c1: #00a884; --c2: #3b82f6; --c3: #f59e0b; --c4: #8b5cf6; --c5: #ec4899;
  --shadow: 0 1px 2px rgba(16, 32, 28, .04), 0 1px 1px rgba(16, 32, 28, .03);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1513; --surface: #151e1b; --surface-2: #1a2522; --line: #24312d; --line-2: #1f2a27;
    --ink: #e7efec; --muted: #9aaaa5; --hint: #6f7f7a;
    --brand: #19c39b; --brand-ink: #4fd8b4; --brand-dark: #19c39b; --brand-soft: #123a31;
    --red: #f06a6a; --red-soft: #3a1d1d; --amber-soft: #3a2f16;
    --c1: #19c39b; --c2: #60a5fa; --c3: #fbbf24; --c4: #a78bfa; --c5: #f472b6;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1513; --surface: #151e1b; --surface-2: #1a2522; --line: #24312d; --line-2: #1f2a27;
  --ink: #e7efec; --muted: #9aaaa5; --hint: #6f7f7a;
  --brand: #19c39b; --brand-ink: #4fd8b4; --brand-dark: #19c39b; --brand-soft: #123a31;
  --red: #f06a6a; --red-soft: #3a1d1d; --amber-soft: #3a2f16;
  --c1: #19c39b; --c2: #60a5fa; --c3: #fbbf24; --c4: #a78bfa; --c5: #f472b6;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.6 "Plex", "Segoe UI", Tahoma, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); text-decoration: none; }
.num, .ltr { direction: ltr; unicode-bidi: isolate; }
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot img { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; transform: scale(.94); } }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-inline-end: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { display: block; font-size: 16px; }
.brand small { color: var(--hint); font-size: 11.5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.side .foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--hint); }
.side .foot .who { color: var(--muted); word-break: break-all; margin-bottom: 6px; }

.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 18px; margin: 0; font-weight: 600; flex: 1; }
.page { padding: 22px 28px 48px; max-width: 1400px; }
.menu-btn { display: none; }

/* ---------- controls ---------- */
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 4px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.icon-btn { width: 36px; height: 36px; padding: 0; }
.icon-btn svg { width: 18px; height: 18px; }
.input, select.input, textarea.input { height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); outline: none; min-width: 0; }
textarea.input { height: auto; padding: 8px 12px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 500; }

/* ---------- cards & grids ---------- */
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-wide { grid-template-columns: 2fr 1fr; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0 0 2px; font-size: 14.5px; font-weight: 600; }
.card .sub { color: var(--hint); font-size: 12px; margin: 0 0 12px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section { margin-top: 14px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .lbl { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.kpi .lbl i { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-style: normal; }
.kpi .lbl i svg { width: 15px; height: 15px; }
.kpi .val { font-size: 26px; font-weight: 600; letter-spacing: -.3px; line-height: 1.25; }
.kpi .meta { font-size: 12px; color: var(--hint); }
.delta { font-weight: 600; font-size: 12px; }
.delta.up { color: var(--brand-ink); } .delta.down { color: var(--red); }
.chart { position: relative; height: 260px; min-width: 0; }
.chart canvas { max-width: 100%; }
.grid > * { min-width: 0; }
.chart.sm { height: 210px; }
.chart.xs { height: 170px; }
.empty { color: var(--hint); text-align: center; padding: 36px 10px; font-size: 13px; }

/* funnel */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel .row { display: grid; grid-template-columns: 130px 1fr 92px; align-items: center; gap: 10px; font-size: 13px; }
.funnel .bar { height: 26px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.funnel .bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-ink)); border-radius: 8px; min-width: 4px; }
.funnel .n { text-align: left; color: var(--muted); }

/* heatmap */
.heat { display: grid; grid-template-columns: 54px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 10.5px; color: var(--hint); }
.heat .c { aspect-ratio: 1; border-radius: 4px; background: var(--surface-2); }
.heat .h { text-align: center; }
.heat .d { display: flex; align-items: center; font-size: 11.5px; color: var(--muted); }

/* lists & tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: right; font-weight: 500; color: var(--hint); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.trial { background: var(--brand-soft); color: var(--brand-ink); }
.badge.pro { background: #ede7fe; color: #6d3fd6; }
.badge.free { background: var(--surface-2); color: var(--muted); }
.badge.blocked, .badge.err { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amber-soft); color: #a86a00; }
:root[data-theme="dark"] .badge.pro { background: #2c2350; color: #c4b2ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.pro { background: #2c2350; color: #c4b2ff; } }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filters .input { flex: 0 1 auto; }
.filters .grow { flex: 1 1 220px; }
.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; color: var(--muted); font-size: 12.5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--hint); } .kv dd { margin: 0; }
.list { display: flex; flex-direction: column; }
.list .it { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.list .it:last-child { border-bottom: 0; }
.list .it .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .hint { color: var(--hint); font-size: 12px; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 12px; cursor: pointer; font-size: 13px; }
.back:hover { color: var(--ink); }
.user-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 18px; background: var(--brand-soft); color: var(--brand-ink); flex: none; }
.user-head h2 { margin: 0; font-size: 18px; word-break: break-all; }
.note-box { width: 100%; min-height: 70px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-size: 13px; background: var(--amber-soft); color: #8a5a00; margin-bottom: 14px; }
.alert.ok { background: var(--brand-soft); color: var(--brand-ink); }
.alert.err { background: var(--red-soft); color: var(--red); }
:root[data-theme="dark"] .alert { color: #f4cf7d; }
.ver { font-size: 30px; font-weight: 600; }
.drop { border: 1.5px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface-2); }
.drop.over, .drop:hover { border-color: var(--brand); color: var(--brand-ink); }
.progress { height: 6px; border-radius: 9px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .2s; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .box { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 30px 28px; box-shadow: 0 12px 40px rgba(16, 32, 28, .07); }
.login .logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.login .logo img { width: 40px; height: 40px; border-radius: 11px; }
.login h2 { margin: 0 0 4px; font-size: 19px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login .input { height: 42px; }
.login .btn { height: 42px; }
.code-input { text-align: center; letter-spacing: 8px; font-size: 20px; font-weight: 600; direction: ltr; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 10px; }
.qr svg, .qr img { width: 180px; height: 180px; }
.secret { font-family: Consolas, monospace; font-size: 12.5px; text-align: center; background: var(--surface-2); border-radius: 8px; padding: 8px; word-break: break-all; direction: ltr; user-select: all; }
.err-msg { color: var(--red); font-size: 13px; min-height: 18px; }
.steps { margin: 0 0 14px; padding-inline-start: 18px; color: var(--muted); font-size: 13px; }

/* ---------- dialog & toast ---------- */
.dlg-back { position: fixed; inset: 0; background: rgba(10, 20, 17, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.dlg { width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px; padding: 22px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.dlg h3 { margin: 0 0 6px; font-size: 16.5px; }
.dlg p { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.dlg .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.dlg .ico { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); margin-bottom: 12px; }
.dlg.danger .ico { background: var(--red-soft); color: var(--red); }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: fade .15s; }
.toast.err { background: var(--red); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } .g-wide { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 0 0 auto; width: 250px; z-index: 40; transform: translateX(100%); transition: transform .2s; }
  .shell.nav-open .side { transform: none; box-shadow: -10px 0 40px rgba(0, 0, 0, .2); }
  .menu-btn { display: inline-flex; }
  .top { padding: 12px 16px; flex-wrap: wrap; }
  .page { padding: 16px 16px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .funnel .row { grid-template-columns: 90px 1fr 70px; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: 1fr 1fr; } .kpi .val { font-size: 21px; } .heat { grid-template-columns: 40px repeat(24, minmax(0, 1fr)); gap: 2px; } }

/* icon sizes inside controls */
.btn svg, .back svg, .alert svg { width: 16px; height: 16px; flex: none; }
.back svg { transform: scaleX(1); }
.dlg .ico svg { width: 20px; height: 20px; }
.drop svg { width: 24px; height: 24px; margin-bottom: 4px; }
.list .it > svg { width: 16px; height: 16px; color: var(--brand-ink); flex: none; }
.top h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 520px) { .seg button { padding: 4px 8px; font-size: 12px; } .top { gap: 8px; } }
