:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --ink: #1c2733;
    --muted: #6b7785;
    --line: #dde3ea;
    --teacher: #1f6f54;
    --teacher-bg: #e3f2ec;
    --student: #38506b;
    --student-bg: #e6ecf3;
    --admin: #7a2e4d;
    --admin-bg: #f6e6ed;
    --danger: #b3321f;
    --radius: 8px;
}

.roles-page {
    max-width: 960px;
    margin: 2rem auto;
    padding: 0 1rem;
    color: var(--ink);
}

.roles-header h1 { margin: 0 0 .25rem; font-size: 1.75rem; }
.roles-header p  { margin: 0 0 1.5rem; color: var(--muted); }

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* Messages */
.roles-alert {
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius);
    border-left: 4px solid;
}
.roles-alert--ok    { background: var(--teacher-bg); border-color: var(--teacher); }
.roles-alert--error { background: #fbe9e6; border-color: var(--danger); }

/* Search and filter */
.roles-toolbar {
    display: flex; flex-wrap: wrap; gap: .75rem;
    margin-bottom: 1rem;
}
.roles-toolbar input[type="search"] {
    flex: 1 1 240px;
    padding: .55rem .75rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font: inherit;
}
.roles-filter { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.roles-filter button {
    padding: .55rem .9rem; border: 0; background: var(--surface);
    font: inherit; cursor: pointer; color: var(--ink);
}
.roles-filter button + button { border-left: 1px solid var(--line); }
.roles-filter button.is-active { background: var(--ink); color: #fff; }

/* Table */
.roles-table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow-x: auto;
}
.roles-table { width: 100%; border-collapse: collapse; }
.roles-table th, .roles-table td {
    padding: .8rem 1rem; text-align: left; vertical-align: middle;
    border-bottom: 1px solid var(--line);
}
.roles-table th { font-weight: 600; background: var(--bg); }
.roles-table tbody tr:last-child td { border-bottom: 0; }
.roles-table tbody tr:hover { background: #fafbfc; }
.col-action { text-align: right !important; white-space: nowrap; }
.muted { color: var(--muted); font-size: .9rem; }
.roles-empty { padding: 1.5rem; text-align: center; color: var(--muted); margin: 0; }

/* Role badges */
.badge {
    display: inline-block; padding: .15rem .6rem; margin-right: .25rem;
    border-radius: 999px; font-size: .85rem; font-weight: 600;
}
.badge--student { background: var(--student-bg); color: var(--student); }
.badge--teacher { background: var(--teacher-bg); color: var(--teacher); }
.badge--admin   { background: var(--admin-bg);   color: var(--admin); }

/* Buttons */
.btn {
    padding: .45rem .9rem; border-radius: var(--radius);
    border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer;
}
.btn--make   { background: var(--teacher); color: #fff; }
.btn--make:hover { background: #185a44; }
.btn--remove { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn--remove:hover { background: #fbe9e6; }
.btn--ghost  { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn[disabled] { opacity: .6; cursor: wait; }

:is(.btn, .roles-filter button, input[type="search"]):focus-visible {
    outline: 3px solid #5b9bd5; outline-offset: 2px;
}

/* Confirm dialog */
.roles-dialog { border: 0; border-radius: var(--radius); padding: 1.5rem; max-width: 380px; }
.roles-dialog::backdrop { background: rgba(28, 39, 51, .45); }
.roles-dialog p { margin: 0 0 1.25rem; }
.roles-dialog__actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* Phones: each row becomes a stacked card */
@media (max-width: 640px) {
    .roles-table thead { display: none; }
    .roles-table, .roles-table tbody, .roles-table tr, .roles-table td { display: block; }
    .roles-table tr { padding: .5rem 0; border-bottom: 1px solid var(--line); }
    .roles-table td { border: 0; padding: .3rem 1rem; }
    .roles-table td[data-label]::before {
        content: attr(data-label) ": "; color: var(--muted); font-size: .85rem;
    }
    .col-action { text-align: left !important; }
}