.mg-rh-wrap,
.mg-rh-wrap *,
.mg-rh-wrap *::before,
.mg-rh-wrap *::after {
    box-sizing: border-box;
}

.mg-rh-wrap {
    max-width: 800px;
    width: 100%;
    margin: 20px 0;
    font-family: inherit;
    overflow-x: hidden;
}

.mg-rh-locked {
    background: #f4f6f8;
    border: 1px solid #dce1e6;
    border-radius: 8px;
    padding: 24px 16px;
    text-align: center;
}

.mg-rh-lock-icon { font-size: 26px; margin-bottom: 6px; }

.mg-rh-login-form {
    max-width: 320px;
    margin: 16px auto 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}
.mg-rh-login-form label { font-weight: 600; font-size: 13px; margin-top: 8px; }
.mg-rh-login-form input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #dce1e6;
    border-radius: 7px;
    font-size: 14px;
}
.mg-rh-login-form .mg-rh-btn { margin-top: 14px; width: 100%; }
#mg-rh-login-msg { font-size: 13px; margin-top: 8px; text-align: center; }

.mg-rh-pw-notice {
    background: #fff4e5;
    border: 1px solid #f0c36d;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}

.mg-rh-pw-notice a { font-weight: 600; }

.mg-rh-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid #dce1e6;
    margin-bottom: 20px;
}

.mg-rh-tab-btn {
    background: none;
    border: none;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    color: #5a6570;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.mg-rh-tab-btn.active {
    color: #0b3d91;
    border-bottom-color: #0b3d91;
}

.mg-rh-tab-content { display: none; }
.mg-rh-tab-content.active { display: block; }

.mg-rh-search {
    flex: 1;
    min-width: 200px;
    max-width: 320px;
    padding: 9px 12px;
    border: 1px solid #dce1e6;
    border-radius: 6px;
    font-size: 14px;
}

.mg-rh-table-wrap { overflow-x: auto; }

.mg-rh-table {
    width: 100%;
    border-collapse: collapse;
}

.mg-rh-table th,
.mg-rh-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e8eb;
    font-size: 14px;
}

.mg-rh-table th {
    background: #0b3d91;
    color: #fff;
    font-weight: 600;
}

.mg-rh-table tbody tr:nth-child(even) { background: #f8f9fb; }

.mg-rh-new-badge {
    background: #1a7a3c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

#mg-rh-submit-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 420px;
}

#mg-rh-submit-form label {
    font-weight: 600;
    margin-top: 10px;
    font-size: 14px;
}

#mg-rh-submit-form input {
    padding: 10px 12px;
    border: 1px solid #dce1e6;
    border-radius: 6px;
    font-size: 14px;
}

.mg-rh-btn {
    margin-top: 16px;
    background: #0b3d91;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    width: fit-content;
}

.mg-rh-btn:hover { background: #092e6e; color: #fff; }

.mg-rh-btn-warn { background: #b36b00; }
.mg-rh-btn-warn:hover { background: #925900; }
.mg-rh-btn-cancel { background: #8a8f94; }
.mg-rh-btn-cancel:hover { background: #6f7378; }

.mg-rh-dupe-box {
    background: #fff8e5;
    border: 1px solid #f0c36d;
    border-radius: 6px;
    padding: 12px 14px;
    margin-top: 10px;
    font-size: 13px;
}

.mg-rh-dupe-box ul { margin: 8px 0 8px 18px; list-style: disc; }
.mg-rh-dupe-box .mg-rh-btn { margin-top: 8px; margin-right: 8px; padding: 8px 14px; }

.mg-rh-note {
    font-size: 12px;
    color: #7a828a;
    margin-top: 6px;
}

/* Rank picker */
.mg-rh-rank-picker {
    max-width: 420px;
    margin-top: 14px;
    border: 1px solid #dce1e6;
    border-radius: 8px;
    padding: 12px 14px;
    background: #fafbfc;
}
.mg-rh-rank-label {
    display: block;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #5a6570;
    margin-bottom: 8px;
}
.mg-rh-forall-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13.5px;
    padding: 6px 8px;
    background: #eef2f6;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 10px;
}
.mg-rh-rank-picker.mg-rh-forall-active .mg-rh-dept-list { opacity: 0.45; pointer-events: none; }
.mg-rh-dept { border-top: 1px solid #e5e8eb; }
.mg-rh-dept:first-child { border-top: none; }
.mg-rh-dept-toggle {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 8px 4px;
    font-size: 13px;
    font-weight: 600;
    color: #24303d;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}
.mg-rh-chevron { transition: transform 0.15s; color: #7a828a; }
.mg-rh-dept.open .mg-rh-chevron { transform: rotate(180deg); }
.mg-rh-dept-ranks {
    display: none;
    flex-wrap: wrap;
    gap: 4px 14px;
    padding: 2px 4px 10px;
}
.mg-rh-dept.open .mg-rh-dept-ranks { display: flex; }
.mg-rh-rank-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 3px 0;
    min-width: 45%;
}

/* Rank pills in table */
.mg-rh-ranks-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.mg-rh-rank-pill {
    display: inline-block;
    background: #eef2f6;
    color: #17457e;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}
.mg-rh-rank-pill-all { background: #fff4d6; color: #8a6300; }

/* Filters row above resources table */
.mg-rh-filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 14px;
}
.mg-rh-rank-filter {
    padding: 9px 12px;
    border: 1px solid #dce1e6;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
}

#mg-rh-submit-msg { font-size: 14px; margin-top: 8px; }
.mg-rh-success { color: #1a7a3c; font-weight: 600; }
.mg-rh-error { color: #b32d2e; font-weight: 600; }

.mg-rh-my-submissions {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid #e5e8eb;
    max-width: 500px;
}

.mg-rh-contributor-cell { line-height: 1.5; }
.mg-rh-contributor-name { display: block; font-weight: 600; color: #24303d; }
.mg-rh-contributor-meta { display: block; font-size: 12px; color: #7a828a; }
.mg-rh-contrib-count {
    display: inline-block;
    margin-top: 2px;
    background: #eef2f6;
    color: #0b3d91;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
}

.mg-rh-my-submissions h4 { margin-bottom: 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.mg-rh-total-count {
    font-size: 11px;
    font-weight: 700;
    color: #0b3d91;
    background: #eef2f6;
    padding: 2px 8px;
    border-radius: 10px;
}
.mg-rh-my-submissions ul { list-style: none; padding: 0; margin: 0; }
.mg-rh-my-submissions li { font-size: 13px; padding: 5px 0; }

.mg-rh-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.mg-rh-status-approved { background: #1a7a3c; }
.mg-rh-status-pending { background: #b36b00; }
.mg-rh-status-rejected { background: #b32d2e; }

.mg-rh-wa-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #e7f8ee;
    color: #1a7a3c;
    font-size: 12.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 14px;
    text-decoration: none;
    white-space: nowrap;
}
.mg-rh-wa-link:hover { background: #d3f2df; }

/* Moderate tab */
.mg-rh-mod-card {
    border: 1px solid #dce1e6;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    background: #fff;
}
.mg-rh-mod-main { flex: 1; min-width: 200px; }
.mg-rh-mod-topic { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; }
.mg-rh-mod-meta { font-size: 12.5px; color: #7a828a; margin-bottom: 6px; }
.mg-rh-mod-ranks { margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.mg-rh-mod-link { font-size: 13px; color: #17457e; font-weight: 600; text-decoration: none; }
.mg-rh-mod-link:hover { text-decoration: underline; }
.mg-rh-mod-actions { display: flex; gap: 8px; flex-shrink: 0; }
.mg-rh-mod-actions .mg-rh-btn { margin-top: 0; padding: 8px 16px; font-size: 13px; }
.mg-rh-mod-empty { color: #7a828a; font-size: 14px; padding: 20px 0; text-align: center; }
@media (max-width: 600px) {
    .mg-rh-table thead { display: none; }
    .mg-rh-table, .mg-rh-table tbody, .mg-rh-table tr, .mg-rh-table td { display: block; width: 100%; }
    .mg-rh-table tr { margin-bottom: 12px; border: 1px solid #e5e8eb; border-radius: 6px; padding: 8px; }
    .mg-rh-table td { border: none; padding: 6px 8px; }
    .mg-rh-table td::before {
        content: attr(data-label);
        font-weight: 700;
        display: block;
        font-size: 11px;
        text-transform: uppercase;
        color: #7a828a;
    }

    .mg-rh-ranks-cell { flex-wrap: wrap; }

    .mg-rh-filters-row { flex-direction: column; }
    .mg-rh-search,
    .mg-rh-rank-filter {
        max-width: 100%;
        width: 100%;
    }

    #mg-rh-submit-form,
    .mg-rh-rank-picker,
    .mg-rh-my-submissions {
        max-width: 100%;
    }

    .mg-rh-rank-row { min-width: 100%; }

    .mg-rh-btn { width: 100%; text-align: center; }
    .mg-rh-dupe-box { display: flex; flex-direction: column; }
    .mg-rh-dupe-box .mg-rh-btn { width: 100%; margin-right: 0; margin-top: 8px; }

    .mg-rh-tabs { gap: 0; }
    .mg-rh-tab-btn { flex: 1; padding: 9px 6px; font-size: 13.5px; }

    .mg-rh-login-form { max-width: 100%; }

    .mg-rh-mod-card { flex-direction: column; }
    .mg-rh-mod-actions { width: 100%; }
    .mg-rh-mod-actions .mg-rh-btn { flex: 1; }
}

@media (max-width: 380px) {
    .mg-rh-table td { font-size: 13px; }
    .mg-rh-locked { padding: 20px 12px; }
}
