:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --ink: #172033;
    --muted: #667085;
    --border: #e5e7eb;
    --primary: #0a2640;
    --primary-soft: rgba(14, 202, 109, .07);
    --success: #0eca6d;
    --danger: #dc2626;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.right { text-align: right; }
.full { width: 100%; }

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(14, 202, 109, .16), transparent 36%),
        linear-gradient(135deg, #0a2640, #163a5a 55%, #f5f7fb 55%);
}
.auth-card {
    width: min(100%, 460px);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 34px;
}
.small-card { text-align: center; }
.brand-mark {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 800;
    margin-bottom: 18px;
}
.auth-card h1, .dashboard-header h1 { margin: 0 0 8px; }
.auth-card p { line-height: 1.6; }
.secure-note {
    margin-top: 20px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #166534;
    background: rgba(34, 197, 94, .1);
    font-size: 13px;
}

.field-group { margin-bottom: 18px; }
.field-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 14px;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 12px 14px;
    outline: none;
    background: #fff;
}
input:focus, select:focus, textarea:focus, .rich-editor:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 4px rgba(14, 202, 109, .12);
}
.password-section { margin-top: 16px; }

.btn {
    border: none;
    border-radius: 13px;
    padding: 11px 16px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.primary { background: var(--primary); color: white; }
.success { background: var(--success); color: white; }
.danger { background: var(--danger); color: white; }
.neutral { background: #eef2f7; color: #172033; }
.outline { background: transparent; border: 1px solid currentColor; }
.message { margin-top: 14px; font-weight: 700; min-height: 20px; }
.message.error { color: var(--danger); }
.message.success { color: #15803d; }

.alert {
    margin-bottom: 18px;
    padding: 13px 16px;
    border-radius: 13px;
    font-weight: 700;
}
.error-alert {
    color: #991b1b;
    background: rgba(220, 38, 38, .10);
    border: 1px solid rgba(220, 38, 38, .22);
}


.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 268px;
    min-height: 100vh;
    background: var(--primary);
    color: white;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
}
.sidebar-logo { font-size: 22px; font-weight: 900; margin-bottom: 28px; }
.sidebar-nav { display: grid; gap: 10px; }
.nav-tab {
    border: none;
    border-radius: 14px;
    padding: 13px 16px;
    color: white;
    background: rgba(255,255,255,.09);
    text-align: left;
    font-weight: 800;
    cursor: pointer;
}
.nav-tab.active { background: var(--success); color: #052012; }
.logout-form { margin: 0; }
.main-panel { flex: 1; padding: 28px; overflow: auto; }
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
.dashboard-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}
.toolbar-card, .table-card, .modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.toolbar-card {
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 190px 190px auto;
    gap: 12px;
    margin-bottom: 18px;
}
.table-card { padding: 8px; }
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table th { color: var(--muted); font-size: 13px; text-align: left; }
.data-table tr:last-child td { border-bottom: none; }
.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
    background: #eef2f7;
}
.badge.Published { background: rgba(14, 202, 109, .14); color: #166534; }
.badge.Draft { background: rgba(100, 116, 139, .16); color: #334155; }
.badge.Scheduled { background: rgba(245, 158, 11, .16); color: #92400e; }
.badge.Archived { background: rgba(220, 38, 38, .12); color: #991b1b; }
.badge.Test { background: rgba(59, 130, 246, .14); color: #1d4ed8; }
.badge.Live { background: rgba(14, 202, 109, .14); color: #166534; }
.badge.Both { background: rgba(124, 58, 237, .14); color: #6d28d9; }
.badge.Unpublished { background: rgba(100, 116, 139, .14); color: #475569; }
.action-row { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.action-row .btn { padding: 8px 10px; font-size: 13px; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, .62);
    display: grid;
    place-items: center;
    padding: 20px;
    z-index: 20;
}
.modal {
    width: min(100%, 960px);
    max-height: 92vh;
    overflow-y: auto;
    padding: 24px;
}
.large-modal { width: min(100%, 1050px); }
.preview-modal { width: min(100%, 780px); }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
    margin-bottom: 18px;
}
.modal-header h2 { margin: 0; }
.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #eef2f7;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.editor-toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    background: #f8fafc;
}
.editor-toolbar button {
    border: 1px solid var(--border);
    background: white;
    border-radius: 10px;
    padding: 7px 10px;
    cursor: pointer;
}
.rich-editor {
    min-height: 220px;
    border: 1px solid var(--border);
    border-top: 0;
    border-radius: 0 0 14px 14px;
    padding: 14px;
    background: white;
    line-height: 1.65;
    outline: none;
}

.publish-options {
    min-height: 86px;
}
.inline-checks {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.inline-checks label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-weight: 700;
}
.inline-checks input {
    width: auto;
}

.checkbox-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    min-height: 86px;
}
.checkbox-stack label { display: flex; align-items: center; gap: 9px; margin: 0; }
.checkbox-stack input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.news-preview { line-height: 1.75; }
.news-preview h1 { margin-top: 0; }
.news-preview img { width: 100%; max-height: 340px; object-fit: cover; border-radius: 16px; margin-bottom: 16px; }
.preview-meta { color: var(--muted); font-weight: 700; margin-bottom: 10px; }

@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; min-height: auto; position: static; }
    .logout-form { margin-top: 0; }
    .toolbar-card, .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
    .dashboard-header { flex-direction: column; align-items: flex-start; }
    .dashboard-actions { width: 100%; justify-content: flex-start; }
}

/* SuperAdmin account switcher */
.dashboard-heading {
    min-width: min(100%, 620px);
}

.admin-switcher {
    display: grid;
    grid-template-columns: auto minmax(260px, 430px);
    align-items: center;
    gap: 8px 12px;
    margin: 14px 0 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
}

.admin-switcher label {
    margin: 0;
    color: var(--primary);
    font-weight: 900;
    white-space: nowrap;
}

.admin-switcher select {
    min-width: 0;
    font-weight: 800;
    color: var(--primary);
    background: #f8fafc;
}

.admin-switcher small {
    grid-column: 1 / -1;
}

.btn.disabled,
.btn[aria-disabled="true"] {
    pointer-events: none;
    opacity: .55;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    .admin-switcher {
        grid-template-columns: 1fr;
        width: 100%;
    }

    .admin-switcher small {
        grid-column: auto;
    }
}


/* Module permissions and email settings */
.module-section { width: 100%; }
.settings-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}
.settings-card textarea { min-height: 180px; resize: vertical; }
.permission-table input[type="checkbox"] { width: 20px; height: 20px; }
.permission-table td:not(:first-child), .permission-table th:not(:first-child) { text-align: center; }

.account-permission-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-top: 18px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fafc;
}
.account-permission-row p { margin: 5px 0 0; }
.permission-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
    white-space: nowrap;
}
.permission-toggle-label input { width: 20px; height: 20px; }
.field-help {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}
input:disabled {
    color: #475569;
    background: #eef2f7;
    cursor: not-allowed;
    opacity: 1;
}

@media (max-width: 620px) {
    .account-permission-row { align-items: flex-start; flex-direction: column; }
}


/* SuperAdmin selector positioned below the sidebar logo */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.sidebar-admin-switcher {
    width: 100%;
    margin: -10px 0 14px;
}

.sidebar-admin-select {
    width: 100%;
    min-width: 0;
    height: 48px;
    padding: 0 38px 0 14px;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 13px;
    background: #ffffff;
    color: var(--primary);
    font-size: 14px;
    font-weight: 850;
    cursor: pointer;
    outline: none;
}

.sidebar-admin-select:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 4px rgba(14, 202, 109, .22);
}

@media (max-width: 900px) {
    .sidebar-admin-switcher {
        max-width: 420px;
        margin-top: 0;
    }
}


/* SuperAdmin create-admin action */
.sidebar-footer-actions {
    margin-top: auto;
    display: grid;
    gap: 12px;
    width: 100%;
}

.sidebar-create-admin-btn {
    min-height: 50px;
    border: 2px solid var(--success);
    background: var(--success);
    color: #052012;
    letter-spacing: .02em;
}

.sidebar-create-admin-btn:hover,
.sidebar-create-admin-btn:focus-visible {
    background: #ffffff;
    color: var(--primary);
    border-color: #ffffff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
}

.create-admin-modal {
    width: min(100%, 760px);
}

.create-admin-subtitle {
    margin: 6px 0 0;
}

.optional-label {
    color: var(--muted);
    font-weight: 600;
}

.admin-password-wrap {
    position: relative;
}

.admin-password-wrap input {
    padding-right: 72px;
}

.admin-password-toggle {
    position: absolute;
    top: 50%;
    right: 9px;
    transform: translateY(-50%);
    min-width: 52px;
    border: 0;
    border-radius: 9px;
    padding: 7px 8px;
    background: #eef2f7;
    color: var(--primary);
    font-weight: 800;
    cursor: pointer;
}

.admin-password-toggle:hover,
.admin-password-toggle:focus-visible {
    background: var(--primary-soft);
    outline: none;
}

.field-error {
    display: block;
    min-height: 18px;
    margin-top: 6px;
    color: var(--danger);
    font-size: 12px;
    font-weight: 700;
}

.input-invalid {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, .10) !important;
}

body.modal-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .sidebar-footer-actions {
        margin-top: 18px;
        max-width: 420px;
    }
}

@media (max-width: 620px) {
    .create-admin-modal {
        padding: 18px;
    }

    .create-admin-modal .modal-actions .btn {
        flex: 1 1 100%;
    }
}
