:root {
    --admin-bg: #f2f5fb;
    --admin-blue: #0f2f67;
    --admin-blue-2: #17458f;
    --admin-gold: #c9a53a;
    --admin-line: rgba(15, 47, 103, 0.16);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    background: var(--admin-bg);
    color: #1f2b43;
    position: relative;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

.admin-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.admin-sidebar {
    background: linear-gradient(165deg, var(--admin-blue), #132647);
    color: #fff;
    padding: 18px;
}

.admin-brand {
    font-family: 'El Messiri', sans-serif;
    font-size: 1.2rem;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.admin-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 8px;
}

.admin-menu a {
    display: block;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
}

.admin-menu a.active,
.admin-menu a:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.18);
}

.admin-main {
    padding: 18px;
}

.admin-top {
    background: #fff;
    border: 1px solid var(--admin-line);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.admin-top-start {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.admin-menu-toggle {
    display: none;
    border: 1px solid var(--admin-line);
    background: #fff;
    color: var(--admin-blue);
    border-radius: 10px;
    padding: 8px 12px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}

.admin-card {
    background: #fff;
    border: 1px solid var(--admin-line);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
}

.admin-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat-box {
    background: #fff;
    border: 1px solid var(--admin-line);
    border-radius: 12px;
    padding: 14px;
}

.stat-box h3 {
    margin: 0;
    color: var(--admin-blue);
    font-size: 1.9rem;
}

.stat-box p {
    margin: 6px 0 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th, td {
    border-bottom: 1px solid var(--admin-line);
    padding: 10px;
    text-align: right;
    vertical-align: top;
}

th {
    color: var(--admin-blue);
}

.admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--admin-line);
    border-radius: 12px;
}

.admin-table-wrap table {
    border: none;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--admin-line);
    border-radius: 9px;
    padding: 10px;
    font-family: inherit;
}

.form-grid {
    display: grid;
    gap: 10px;
}

.rich-editor {
    border: 1px solid var(--admin-line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.rich-editor-toolbar {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid var(--admin-line);
    background: #f7f9fd;
}

.rich-editor-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 11px;
    border: 1px solid var(--admin-line);
    border-radius: 8px;
    background: #fff;
    color: var(--admin-blue);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}

.rich-editor-button:hover {
    background: #eef3fb;
}

.rich-editor-surface {
    display: none;
    min-height: 280px;
    padding: 14px;
    line-height: 1.9;
    outline: none;
}

.rich-editor-surface:empty::before {
    content: attr(data-placeholder);
    color: #7c8597;
}

.rich-editor-surface .text-center {
    text-align: center;
}

.rich-editor-surface .text-right {
    text-align: right;
}

.rich-editor-surface .text-left {
    text-align: left;
}

.rich-editor-surface p,
.rich-editor-surface ul,
.rich-editor-surface ol,
.rich-editor-surface blockquote,
.rich-editor-surface h2,
.rich-editor-surface h3,
.rich-editor-surface h4 {
    margin: 0 0 12px;
}

.rich-editor-surface ul,
.rich-editor-surface ol {
    padding-inline-start: 24px;
}

.rich-editor-surface blockquote {
    padding: 12px 16px;
    border-inline-start: 4px solid var(--admin-blue-2);
    background: rgba(23, 69, 143, 0.08);
    border-radius: 10px;
}

.rich-editor-source {
    border: 0;
    border-radius: 0;
    min-height: 220px;
    font-family: Consolas, 'Courier New', monospace;
    direction: ltr;
}

.rich-editor.is-enhanced .rich-editor-toolbar {
    display: flex;
}

.rich-editor.is-enhanced .rich-editor-surface {
    display: block;
}

.rich-editor.is-enhanced .rich-editor-source {
    display: none;
    border-top: 1px solid var(--admin-line);
}

.rich-editor-source.is-visible {
    display: block;
}

.rich-editor-help {
    padding: 10px 14px 14px;
    color: #5d6780;
    font-size: 0.92rem;
    line-height: 1.8;
}

.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.inline-check input[type='checkbox'] {
    width: auto;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--admin-line);
    font-weight: 600;
    cursor: pointer;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-primary {
    background: var(--admin-blue);
    color: #fff;
    border-color: var(--admin-blue);
}

.btn-gold {
    background: var(--admin-gold);
    color: #2b230c;
    border-color: #b49234;
}

.btn-danger {
    background: #b83838;
    color: #fff;
    border-color: #9b2f2f;
}

.notice {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.notice.success { background: #e7f7ec; color: #1f6c3f; border: 1px solid #9dd3ae; }
.notice.error { background: #ffe9e9; color: #952323; border: 1px solid #edb2b2; }

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top, rgba(23, 69, 143, 0.18), transparent 40%), #eef2f9;
}

.login-card {
    width: min(460px, 92%);
    background: #fff;
    border: 1px solid var(--admin-line);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 16px 36px rgba(15, 47, 103, 0.1);
}

@media (max-width: 1100px) {
    .admin-layout {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(320px, 88vw);
        z-index: 100;
        overflow-y: auto;
        transform: translateX(110%);
        transition: transform .25s ease;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.22);
    }

    body.admin-menu-open .admin-sidebar {
        transform: translateX(0);
    }

    body.admin-menu-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 90;
    }

    .admin-main {
        padding: 14px;
    }

    .admin-top {
        position: sticky;
        top: 10px;
        z-index: 60;
        flex-wrap: wrap;
    }

    .admin-menu-toggle {
        display: inline-flex;
    }

    .admin-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .admin-grid-4 {
        grid-template-columns: 1fr;
    }

    .admin-top span {
        width: 100%;
    }

    .admin-card {
        padding: 12px;
    }

    table {
        min-width: 640px;
    }

    .admin-actions .btn {
        flex: 1 1 calc(50% - 6px);
    }

    .btn {
        width: 100%;
    }

    .admin-actions .btn {
        width: auto;
    }
}
