* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: #f1f5f9; color: #1e293b; line-height: 1.6;
}
a { text-decoration: none; color: inherit; }

/* ===== Topbar ===== */
.topbar { background: linear-gradient(135deg, #7c3aed, #6d28d9); color: #fff; box-shadow: 0 4px 18px rgba(124,58,237,.25); }
.topbar-in { max-width: 1080px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.brand { font-size: 22px; font-weight: 900; letter-spacing: .5px; }
.nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.nav a { font-weight: 700; opacity: .95; }
.nav a:hover { opacity: 1; text-decoration: underline; }
.nav-admin { background: rgba(255,255,255,.18); padding: 6px 12px; border-radius: 8px; }
.nav-out { background: rgba(0,0,0,.2); padding: 6px 12px; border-radius: 8px; }
.bal { background: #fff; color: #6d28d9; padding: 6px 12px; border-radius: 999px; font-weight: 900; font-size: 14px; }

/* ===== Layout ===== */
.wrap { max-width: 1080px; margin: 20px auto; padding: 0 16px; }
.card-panel { background: #fff; border-radius: 16px; box-shadow: 0 8px 30px rgba(0,0,0,.06); padding: 20px; margin-bottom: 18px; }
h1 { font-size: 22px; margin-bottom: 14px; }
h2 { font-size: 18px; margin-bottom: 12px; }

/* ===== Categories & Offers grids ===== */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-items: stretch; }
.cat-card {
    background: #fff; border: 2px solid #e2e8f0; border-radius: 14px; padding: 14px 10px;
    text-align: center; cursor: pointer; transition: .15s; font-weight: 800;
    height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; font-size: 13px; line-height: 1.3; overflow: hidden;
    word-break: break-word;
}
.cat-card > :not(.cat-bg):not(.cat-emoji) {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.cat-card:hover { border-color: #a78bfa; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(124,58,237,.15); }
.cat-emoji { font-size: 30px; display: block; }

.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.offer-card {
    border: 2px solid #e2e8f0; border-radius: 14px; padding: 14px; background: #fff;
    cursor: pointer; transition: .15s; display: flex; flex-direction: column; gap: 6px;
}
.offer-card:hover { border-color: #a78bfa; box-shadow: 0 6px 18px rgba(124,58,237,.14); }
.offer-card.selected { border-color: #7c3aed; background: #faf5ff; box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.offer-name { font-weight: 800; font-size: 14px; }
.offer-price { font-weight: 900; color: #7c3aed; font-size: 16px; }
.offer-cost { font-size: 11px; color: #94a3b8; }

/* ===== Forms ===== */
label { display: block; font-weight: 700; margin: 12px 0 6px; }
input, select { width: 100%; padding: 11px 12px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 15px; font-family: inherit; }
.btn { display: inline-block; padding: 12px 20px; border: none; border-radius: 10px; background: #7c3aed; color: #fff; font-weight: 800; font-size: 15px; cursor: pointer; }
.btn:hover { background: #6d28d9; }
.btn:disabled { background: #cbd5e1; cursor: not-allowed; }
.btn-ghost { background: #eef2ff; color: #4338ca; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== Alerts ===== */
.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 700; }
.alert-ok { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.alert-err { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ===== Table ===== */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px; border-bottom: 1px solid #eef2f7; text-align: center; }
th { background: #f8fafc; font-weight: 800; color: #475569; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.b-success { background: #ecfdf5; color: #047857; }
.b-pending { background: #fffbeb; color: #92400e; }
.b-failed { background: #fef2f2; color: #b91c1c; }

/* ===== Auth pages ===== */
.auth-box { max-width: 420px; margin: 40px auto; }

/* ===== Stats ===== */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat { flex: 1; min-width: 140px; background: #eef2ff; border-radius: 12px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 22px; color: #4338ca; }

.footer { text-align: center; padding: 20px; color: #94a3b8; font-size: 13px; }

@media (max-width: 600px) {
    .brand { font-size: 18px; }
    .nav { gap: 8px; font-size: 14px; }
}

/* ===== صور الفئات ===== */
.cat-wrap { position: relative; display: flex; }
.cat-wrap > .cat-card { flex: 1; }
.cat-card.has-img { position: relative; overflow: hidden; padding: 0; height: 130px; color: #fff; display: flex; align-items: flex-end; justify-content: center; }
.cat-card.has-img .cat-bg { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; }
.cat-card.has-img .cat-bg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.72) 0%, rgba(0,0,0,.15) 60%, rgba(0,0,0,0) 100%); }
.cat-card.has-img .cat-label-over { position: relative; z-index: 1; font-weight: 800; font-size: 13px; padding: 8px; text-shadow: 0 1px 3px rgba(0,0,0,.7); text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cat-img-btn { position: absolute; top: 5px; right: 5px; z-index: 3; width: 24px; height: 24px; border-radius: 50%; background: rgba(124,58,237,.9); color: #fff; border: none; font-size: 15px; font-weight: 800; cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center; opacity: .85; }
.cat-img-btn:hover { opacity: 1; }
.cat-img-del-f { position: absolute; top: 5px; left: 5px; z-index: 3; margin: 0; }
.cat-img-del { width: 24px; height: 24px; border-radius: 50%; background: rgba(220,38,38,.9); color: #fff; border: none; font-size: 13px; cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center; }

/* منع انقلاب الأرقام في RTL */
.bal, td, .offer-price, .stat b, .cost { unicode-bidi: plaintext; }
