* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --danger: #dc2626;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(15, 23, 42, .08);
}

body {
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ═══ تسجيل الدخول ═══ */
#login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(150deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px 28px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 12px; }
.login-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-sub { color: var(--muted); margin-bottom: 20px; }

/* ═══ الحقول والأزرار ═══ */
input, select {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
    color: var(--text);
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
}

label {
    display: block;
    text-align: right;
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--muted);
}

.btn {
    padding: 11px 18px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
.btn:active { opacity: .8; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-ghost { background: transparent; color: inherit; }
.btn-block { width: 100%; }

.error-msg {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: .9rem;
}

/* ═══ الشريط العلوي ═══ */
.topbar {
    background: var(--primary);
    color: #fff;
    padding: 12px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title { font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.topbar-actions { display: flex; gap: 4px; }
.topbar .btn-ghost { color: #fff; font-size: .9rem; padding: 8px 10px; }

.badge {
    background: rgba(255, 255, 255, .2);
    font-size: .72rem;
    font-weight: 400;
    padding: 3px 10px;
    border-radius: 99px;
}

/* ═══ البحث ═══ */
.search-wrap {
    padding: 14px 16px 4px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

#search-input {
    font-size: 1.05rem;
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border-color: transparent;
    margin-bottom: 0;
}

/* ═══ شبكة الأصناف ═══ */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    padding: 14px 16px 90px;
    max-width: 900px;
    margin: 0 auto;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #e2e8f0;
    display: block;
}

.card-img-placeholder {
    width: 100%;
    aspect-ratio: 1;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #94a3b8;
}

.card-body { padding: 10px 12px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.card-name { font-weight: 600; font-size: .95rem; line-height: 1.4; }
.card-price { color: var(--primary); font-weight: 800; font-size: 1.15rem; margin-top: auto; }

.card-admin {
    display: flex;
    gap: 6px;
    padding: 0 12px 12px;
}
.card-admin button {
    flex: 1;
    padding: 6px;
    font-size: .8rem;
    border-radius: 8px;
}
.btn-edit { background: #f1f5f9; color: var(--text); border: none; cursor: pointer; font-family: inherit; }
.btn-delete { background: #fef2f2; color: var(--danger); border: none; cursor: pointer; font-family: inherit; }

.empty {
    text-align: center;
    color: var(--muted);
    padding: 60px 20px;
    font-size: 1.05rem;
}

/* ═══ زر الإضافة العائم ═══ */
.fab {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 20px;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(15, 118, 110, .45);
    z-index: 20;
}

/* ═══ النوافذ المنبثقة ═══ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 50;
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h2 { margin-bottom: 16px; font-size: 1.2rem; }
.modal h3 { margin: 16px 0 10px; font-size: 1rem; color: var(--muted); }

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
    margin-top: 8px;
}

.img-preview {
    width: 90px;
    height: 90px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 12px;
    border: 1.5px solid #e2e8f0;
}

/* ═══ قائمة الأعضاء ═══ */
.users-list { display: flex; flex-direction: column; gap: 8px; }

.user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #f8fafc;
    padding: 10px 12px;
    border-radius: 10px;
}

.user-row .name { font-weight: 600; }
.user-row .role { font-size: .75rem; color: var(--muted); }
.user-row .actions { display: flex; gap: 4px; }
.user-row .actions button {
    border: none;
    background: #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: .8rem;
    font-family: inherit;
}
.user-row .actions .del { background: #fef2f2; color: var(--danger); }

/* ═══ التنبيهات ═══ */
.toast {
    position: fixed;
    bottom: 90px;
    right: 50%;
    transform: translateX(50%);
    background: #1e293b;
    color: #fff;
    padding: 12px 22px;
    border-radius: 99px;
    font-size: .95rem;
    z-index: 100;
    box-shadow: var(--shadow);
}

@media (max-width: 420px) {
    .grid { grid-template-columns: repeat(2, 1fr); }
}
