body.admin { background: #f3f1ed; }
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: #17161b; color: #d8ccd2; padding: 1.4rem 1rem; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: .3rem;
}
.sidebar .brand { margin-bottom: 1.6rem; padding: 0 .5rem; }
.sidebar .brand strong { color: #fff; }
.sidebar a.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border-radius: 12px; font-weight: 500; transition: .15s;
}
.sidebar a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a.nav-item.active { background: var(--accent); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar form button { width: 100%; background: transparent; color: #d8ccd2; border: 1px solid rgba(255,255,255,.15); }

.admin-main { padding: 1.8rem 2rem 3rem; min-width: 0; }
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.admin-top h1 { margin: 0; font-size: 1.8rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat { background: #fff; border-radius: 18px; padding: 1.1rem 1.2rem; border: 1px solid var(--line); }
.stat .n { font: 800 2rem var(--font-head); line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .9rem; }

.card { background: #fff; border-radius: 18px; border: 1px solid var(--line); padding: 1.3rem; margin-bottom: 1.4rem; }
.card h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

table.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th { text-align: start; color: var(--muted); font-weight: 500; font-size: .85rem; padding: .6rem; border-bottom: 1px solid var(--line); }
.tbl td { padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .thumb { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: var(--bg); display: grid; place-items: center; font-size: 1.3rem; }
.tbl .actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }
.tbl .actions form { margin: 0; }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .15em .65em; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.on { background: #e3f5ea; color: #17673b; }
.badge.off { background: #f3e3e3; color: #8a2a2a; }
.badge.demo { background: #efeafb; color: #4b3b7a; }
.badge.err { background: #fde8e4; color: #a3321f; }

.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.form-card { max-width: 980px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
.form-grid-3 .span-2 { grid-column: span 2; }
.form-grid-3 .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid-3 { grid-template-columns: 1fr; } .form-grid-3 .span-2 { grid-column: auto; } }
.field .val { color: var(--danger); font-size: .82rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.img-prev { width: 90px; height: 90px; border-radius: 14px; object-fit: cover; margin-top: .4rem; border: 1px solid var(--line); }
.validation-summary-errors { background: #fde8e4; color: #a3321f; border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; }
.validation-summary-errors ul { margin: 0; padding-inline-start: 1.2rem; }

.rows-editor .row { display: grid; gap: .5rem; align-items: end; padding: .7rem; border: 1px solid var(--line); border-radius: 14px; margin-bottom: .6rem; background: var(--bg); }
.rows-editor.options .row { grid-template-columns: 1.1fr 1.4fr .8fr .7fr 1fr .8fr auto auto; }
.rows-editor.sizes .row { grid-template-columns: 1fr repeat(6, .9fr) auto; }
.rows-editor .row .field label { font-size: .75rem; font-weight: 500; color: var(--muted); }
.rows-editor .row .field input, .rows-editor .row .field select { padding: .45em .6em; font-size: .9rem; }
.rows-editor .row input[type=color] { height: 38px; padding: 2px; }
.icon-btn { border: 0; background: #fde8e4; color: #a3321f; width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 1rem; }
.hint { font-size: .85rem; color: var(--muted); background: var(--bg); border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem; }
@media (max-width: 1100px) {
  .rows-editor.options .row, .rows-editor.sizes .row { grid-template-columns: repeat(2, 1fr); }
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 20% 20%, #f6dfe7, transparent 50%), radial-gradient(circle at 80% 80%, #f1e6d2, transparent 50%), var(--bg); }
.login-card { background: #fff; border-radius: 26px; padding: 2.2rem; width: min(400px, 100%); box-shadow: var(--shadow-lg); }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar .brand { margin: 0 auto 0 0; }
  .sidebar .spacer { display: none; }
  .admin-main { padding: 1.2rem; }
}

/* الصور الذكية */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.media-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.media-img { position: relative; aspect-ratio: 3/4; background: var(--bg); }
.media-img img { width: 100%; height: 100%; object-fit: cover; }
.media-img .ph { flex-direction: column; gap: .3rem; color: var(--muted); }
.media-img .ph .i { width: 34px; height: 34px; }
.media-img .busy { position: absolute; inset: 0; background: rgba(255,255,255,.75); display: none; place-items: center; }
.media-card.loading .busy { display: grid; }
.media-body { padding: .8rem; display: grid; gap: .2rem; }
.media-acts { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .4rem; }
.media-acts form { margin: 0; }

/* الموبايل (خاصّة iPhone): خانات الكتابة 16px عالأقل، كرمال ما تعمل zoom لحالها لمّا تكبس عليها */
@media (max-width: 900px) {
  input, select, textarea { font-size: 16px !important; }
}
