:root {
  --bg: #0b0d14;
  --bg-2: #10131d;
  --surface: #161a26;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f4f5fb;
  --muted: #9aa3b5;
  --primary: #6c5ce7;
  --primary-2: #8b7bff;
  --green: #22c55e;
  --danger: #ef4444;
  --radius: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  font-family: "Cairo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  transition: border-color .2s;
}
input:focus { outline: none; border-color: var(--primary); }
input::placeholder { color: var(--muted); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -12px rgba(108,92,231,.9); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.small { width: auto; padding: 10px 18px; font-size: 13px; }

.err { color: var(--danger); font-size: 13px; font-weight: 600; }
.msg { font-size: 13px; font-weight: 600; }

.pass-row { position: relative; }
.pass-row input { padding-left: 46px; }
.pass-toggle {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 17px;
  opacity: .7;
  padding: 4px;
}
.pass-toggle:hover { opacity: 1; }
.msg.ok { color: var(--green); }
.msg.bad { color: var(--danger); }
.err[hidden], .msg[hidden] { display: none; }

/* ====== الدخول ====== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 400px;
  padding: 40px 32px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.8);
  text-align: center;
}
.login-logo {
  display: inline-block;
  padding: 8px 20px;
  border-radius: 12px;
  font-size: 26px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  margin-bottom: 18px;
}
.login-box h1 { font-size: 22px; font-weight: 900; margin-bottom: 6px; }
.login-box > p { color: var(--muted); font-size: 14px; margin-bottom: 26px; }
.login-box form { display: flex; flex-direction: column; gap: 14px; }
.back-link { display: inline-block; margin-top: 20px; color: var(--muted); font-size: 13px; text-decoration: none; }
.back-link:hover { color: #fff; }

/* ====== اللوحة ====== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(11, 13, 20, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  padding: 4px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}
.brand-sub { color: var(--muted); font-size: 14px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.admin-name { color: var(--muted); font-size: 13px; }
.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: color .2s, background .2s;
}
.btn-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.btn-link.danger:hover { color: var(--danger); }

.tabs {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tab {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: rgba(255,255,255,.03);
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: color .2s, background .2s;
}
.tab:hover { color: #fff; }
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
}

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}
.tab-panel[hidden] { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card.narrow { max-width: 560px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.card-head h2 { font-size: 18px; font-weight: 800; }
.badge {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-2);
  background: rgba(108,92,231,.15);
}
.hint { color: var(--muted); font-size: 14px; margin-bottom: 18px; }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat-chip .sc-ico {
  width: 42px; height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border-radius: 12px;
  background: rgba(108,92,231,.15);
}
.stat-chip b { display: block; font-size: 20px; font-weight: 900; color: var(--text); }
.stat-chip small { color: var(--muted); font-size: 12px; }

.search-wrap {
  position: relative;
  margin-bottom: 16px;
  max-width: 420px;
}
.search-wrap svg {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--muted);
  pointer-events: none;
}
.search-wrap input {
  padding-right: 42px;
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 130px;
  padding: 20px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: rgba(255,255,255,.03);
  margin-bottom: 18px;
}
.logo-preview img {
  max-width: 220px;
  max-height: 110px;
  object-fit: contain;
}
.logo-placeholder {
  font-size: 40px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.logo-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.logo-actions .btn { width: auto; padding: 12px 22px; font-size: 14px; }
.btn-upload { cursor: pointer; }
.btn-danger {
  color: #fff;
  background: rgba(239,68,68,.85);
}
.btn-danger:hover { background: var(--danger); box-shadow: 0 14px 34px -12px rgba(239,68,68,.8); }
.small-hint { margin-top: 14px; font-size: 12px; }

.brand-controls {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bc-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.bc-head h3 { font-size: 16px; font-weight: 800; }
.bc-head .btn { width: auto; padding: 10px 18px; font-size: 13px; }
.bc-row { display: flex; align-items: center; gap: 14px; }
.bc-row > span { flex: 1; color: var(--muted); font-size: 13px; }
.bc-row input[type="range"] { flex: 1.4; accent-color: var(--primary); }
.bc-row output { width: 52px; text-align: center; color: var(--text); font-weight: 700; font-size: 13px; }
.color-row { display: flex; align-items: center; gap: 8px; flex: 1.4; }
.color-row input[type="color"] {
  width: 44px; height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255,255,255,.06);
  cursor: pointer;
}
.color-row .btn { width: auto; padding: 8px 14px; font-size: 12px; }
.btn.ghost { background: rgba(255,255,255,.06); color: var(--muted); }
.btn.ghost:hover { color: #fff; background: rgba(255,255,255,.12); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: right; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 700; }
td { color: var(--text); }
tr:hover td { background: rgba(255,255,255,.02); }
td.mono, td[dir="ltr"] { font-family: monospace; font-size: 13px; direction: ltr; text-align: left; }
.empty { text-align: center; color: var(--muted); }

#serialForm, #securityForm { display: flex; flex-direction: column; gap: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.serial-result {
  margin-top: 20px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid rgba(34,197,94,.4);
  background: rgba(34,197,94,.08);
}
.serial-label { color: var(--green); font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.serial-value {
  font-family: monospace;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .5px;
  word-break: break-all;
  margin-bottom: 12px;
  user-select: all;
}

@media (max-width: 600px) {
  .row2 { grid-template-columns: 1fr; }
  .tabs { padding: 14px 16px 0; }
  .content { padding: 16px; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
}
