/* ═════════ لوحة إدارة حماية الأسرة ═════════ */
:root {
  --bg: #070b0a;
  --surface: #0e1614;
  --surface-2: #13201c;
  --surface-3: #182823;
  --border: #1e2c27;
  --border-2: #2a3d36;
  --text: #e9f1ee;
  --text-2: #b7c6c1;
  --muted: #7d8f89;
  --brand: #10b981;
  --brand-2: #34d399;
  --brand-soft: rgba(16, 185, 129, .12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .12);
  --shadow: 0 14px 40px rgba(0, 0, 0, .28);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1000px 600px at 90% -10%, rgba(16, 185, 129, .09), transparent 60%), var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: var(--ok); }
.error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 2px 0 0; }
.stack { display: grid; gap: 12px; }

/* splash */
.splash { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border-2); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═════════ الدخول ═════════ */
.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(700px 400px at 80% 0%, rgba(16, 185, 129, .14), transparent 65%),
    radial-gradient(600px 400px at 10% 100%, rgba(52, 211, 153, .06), transparent 60%);
}
.auth-card {
  width: min(440px, 100%);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-title { font-weight: 700; font-size: 16px; }
.auth-sub { color: var(--muted); font-size: 12.5px; }
.auth-card h1 { font-size: 23px; margin: 0 0 6px; letter-spacing: -.2px; }
.auth-card > p { margin: 0 0 20px; font-size: 13.5px; }
.auth-card .btn.ghost { margin-top: 10px; }

.brand-mark {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center;
  background: linear-gradient(145deg, #10b981, #047857);
  color: #04110c; flex: none;
  box-shadow: 0 6px 18px rgba(16, 185, 129, .28);
}
.brand-mark.lg { width: 66px; height: 66px; border-radius: 20px; margin-bottom: 16px; }

.field { display: grid; gap: 6px; }
.field > span, .form-grid label > span { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
input {
  width: 100%; padding: 11px 13px; border-radius: 11px;
  border: 1px solid var(--border-2); background: var(--surface-2);
  color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(16, 185, 129, .12); }
input[readonly] { opacity: .75; }

/* ═════════ أزرار ═════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 11px; border: 1px solid transparent;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: linear-gradient(135deg, #12c48a, #059669); color: #04110c; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.soft { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }
.btn.soft:hover { background: var(--surface-3); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--bad); color: #1b0505; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.link { border: 0; background: none; color: var(--brand-2); font-weight: 600; cursor: pointer; font-size: 12.5px; padding: 0; }
.link:hover { text-decoration: underline; }

/* ═════════ الهيكل ═════════ */
.shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 16px;
  background: linear-gradient(180deg, #0b1210, #08100e);
  border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 6px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -.2px; }
.brand-sub { color: var(--muted); font-size: 11.5px; }
.nav { display: grid; gap: 3px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: 10px; border: none; background: none;
  color: var(--text-2); font-weight: 500; text-align: start; cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-2); font-weight: 600; }
.nav-item .count { margin-inline-start: auto; }
.nav-item svg { flex: none; }
.count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  display: inline-grid; place-items: center; background: var(--brand); color: #04110c;
  font-size: 11px; font-weight: 700;
}
.count:empty { display: none; }

.side-info { margin-top: 2px; padding: 13px 12px; border: 1px solid var(--border); border-radius: 13px; background: var(--surface); }
.side-title { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.mini-stat { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-2); padding: 3px 0; }
.mini-stat b { color: var(--text); }

.side-footer { margin-top: auto; display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); }
.user { display: flex; align-items: center; gap: 9px; min-width: 0; }
.user-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: var(--brand-soft); color: var(--brand-2);
}
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 12px; }
.side-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }

.main { padding: 26px 30px 60px; max-width: 1500px; width: 100%; margin: 0 auto; min-width: 0; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.topbar h1 { font-size: 24px; margin: 0; letter-spacing: -.3px; }
.topbar p { margin: 3px 0 0; font-size: 13px; }
.topbar-end { display: flex; align-items: center; gap: 12px; font-size: 12.5px; }
.live-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px;
  background: var(--ok-soft); color: var(--ok); font-weight: 600; font-size: 12px;
}
.live-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, .18); }

/* ═════════ كروت وإحصائيات ═════════ */
.view { display: grid; gap: 18px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; }
.stat {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, var(--surface), #0b1412);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 17px 18px;
}
.stat::after {
  content: ""; position: absolute; inset-inline-start: -30px; top: -40px;
  width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, var(--c, rgba(16,185,129,.18)), transparent 70%);
  pointer-events: none;
}
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; line-height: 1.25; margin-top: 4px; letter-spacing: -.5px; }
.stat .sub { color: var(--muted); font-size: 11.5px; }
.stat .value.ok { color: var(--ok); }
.stat .value.warn { color: var(--warn); }
.stat .value.bad { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { font-size: 15.5px; margin: 0; font-weight: 600; }
.hint-inline { font-size: 11.5px; color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }
.hint a { color: var(--brand-2); }

/* chart */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 8px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 0; }
.bar-track { width: 100%; max-width: 44px; height: 128px; display: flex; align-items: flex-end; }
.bar {
  width: 100%; border-radius: 8px 8px 3px 3px; min-height: 4px;
  background: linear-gradient(180deg, #34d399, #059669);
  box-shadow: 0 0 18px rgba(16, 185, 129, .22);
  transition: height .4s ease;
}
.bar.today { background: linear-gradient(180deg, #6ee7b7, #10b981); box-shadow: 0 0 22px rgba(16, 185, 129, .4); }
.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar-val { font-size: 11px; color: var(--text-2); font-weight: 600; }

/* mini list */
.mini-list { display: grid; gap: 2px; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); min-width: 0; }
.mini-row:last-child { border-bottom: 0; }
.mini-row .meta { min-width: 0; flex: 1; }
.mini-row .name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .sub { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 26px 10px; }

/* ═════════ أدوات وجداول ═════════ */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; color: var(--muted); padding: 7px 12px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.seg button.active { background: var(--brand-soft); color: var(--brand-2); }
.search { width: min(320px, 100%); }
.table-wrap { padding: 6px 6px 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: start; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
td { font-size: 12.8px; }
tbody tr:hover { background: rgba(255, 255, 255, .017); }
tbody tr:last-child td { border-bottom: 0; }
td .name { font-weight: 600; }
td .sub { color: var(--muted); font-size: 11.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.pill.active, .pill.approved { background: var(--ok-soft); color: var(--ok); }
.pill.pending { background: var(--warn-soft); color: var(--warn); }
.pill.suspended, .pill.rejected { background: var(--bad-soft); color: var(--bad); }

/* ═════════ نماذج ═════════ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; align-items: end; }
.form-grid label { display: grid; gap: 6px; min-width: 0; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid .btn { justify-self: start; }

.apk-preview {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: 12px;
  margin-top: 12px; word-break: break-all;
}
.apk-preview .url { color: var(--brand-2); font-size: 12px; }

/* ═════════ نافذة ═════════ */
.modal { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(2, 6, 5, .72); backdrop-filter: blur(4px); }
.modal-card { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border-2); border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.modal-card h3 { margin: 0 0 4px; font-size: 17px; }
.modal-card > p { margin: 0 0 14px; font-size: 13px; white-space: pre-line; }
.modal-card .field { margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 16px; }

/* toasts */
.toasts { position: fixed; inset-inline-start: 20px; bottom: 20px; z-index: 120; display: grid; gap: 8px; }
.toast {
  background: #12201b; border: 1px solid var(--border-2); color: var(--text);
  padding: 11px 14px; border-radius: 11px; box-shadow: var(--shadow); font-size: 13px;
  animation: pop .2s ease;
}
.toast.err { border-color: rgba(248, 113, 113, .5); }
.toast.ok { border-color: rgba(52, 211, 153, .5); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-inline-end: 0; border-bottom: 1px solid var(--border); }
  .sidebar .brand { padding: 0 8px 0 0; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
  .nav-item { width: auto; padding: 7px 10px; }
  .side-info { display: none; }
  .side-footer { margin: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 8px; }
  .side-footer .user { display: none; }
  .main { padding: 18px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 20px; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .toolbar { align-items: stretch; }
  .seg { overflow-x: auto; }
  .search { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat .value { font-size: 24px; }
}
