:root {
    color-scheme: light;
    --bg: #f5f7f9;
    --panel: #ffffff;
    --text: #18202a;
    --muted: #657181;
    --line: #dce3ea;
    --primary: #136f63;
    --primary-dark: #0f5b51;
    --accent: #d88823;
    --danger: #b3261e;
    --shadow: 0 16px 40px rgba(24, 32, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.sidebar {
    min-height: 100vh;
    padding: 24px;
    background: #111820;
    color: white;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: white;
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small,
.topbar p,
small,
.muted {
    color: var(--muted);
}

.sidebar .brand small {
    color: #b8c4cf;
}

nav {
    display: grid;
    gap: 8px;
}

.nav-group-title {
    color: var(--muted);
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    margin: 14px 10px 2px;
    text-transform: uppercase;
}

nav a,
.logout {
    padding: 12px 14px;
    border-radius: 8px;
    color: #dce6ef;
    text-decoration: none;
}

nav a.active,
nav a:hover,
.logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.logout {
    margin-top: auto;
}

main {
    padding: 30px;
    overflow: auto;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar p,
.topbar h1 {
    margin: 0;
}

.topbar h1 {
    font-size: 32px;
}

.identity {
    text-align: right;
}

.identity span {
    display: block;
    color: var(--muted);
}

.panel,
.metrics article,
.login-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 22px;
}

.panel h2 {
    margin: 0 0 18px;
    font-size: 20px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.metrics article {
    padding: 20px;
}

.metrics span {
    display: block;
    font-size: 34px;
    font-weight: 800;
    color: var(--primary);
}

.grid.two {
    display: grid;
    grid-template-columns: minmax(300px, 420px) 1fr;
    gap: 22px;
    align-items: start;
}

.wide {
    min-width: 0;
}

.accounts-table {
    grid-column: 1 / -1;
}

.systems-table-panel {
    grid-column: 1 / -1;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.form {
    display: grid;
    gap: 14px;
}

.compact-form {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.compact-form:last-child {
    border-bottom: 0;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 18px;
}

.filters label {
    display: grid;
    gap: 7px;
    color: #2f3b48;
    font-weight: 650;
}

.filters .checkbox-line {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

.filters .checkbox-line input {
    width: auto;
}

.form label {
    display: grid;
    gap: 7px;
    color: #2f3b48;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
    background: white;
}

textarea {
    resize: vertical;
}

.students-select-large {
    min-height: 392px;
}

button,
.button {
    border: 0;
    border-radius: 8px;
    padding: 11px 14px;
    background: var(--primary);
    color: white;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
}

button.danger {
    background: var(--danger);
}

button.danger:hover {
    background: #8f1f19;
}

.secondary-action {
    background: #e8eef3;
    color: #1d2a36;
}

.secondary-action:hover {
    background: #d7e1ea;
}

.button.secondary {
    background: #e8eef3;
    color: #1d2a36;
}

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

table {
    width: 100%;
    border-collapse: collapse;
}

.separated-table {
    border-collapse: separate;
    border-spacing: 0 8px;
}

.separated-table th {
    border-bottom: 0;
}

.separated-table tbody tr > td:first-child {
    border-left: 5px solid transparent;
}

tr[hidden] {
    display: none;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
}

.request-band-even > td {
    background: #fff;
}

.request-band-odd > td {
    background: #dfeeea;
}

.requests-table .request-main-row > td {
    border-top: 1px solid #cbd7df;
    border-bottom: 1px solid #cbd7df;
}

.requests-table .request-main-row > td:first-child {
    border-left-color: var(--primary);
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.requests-table .request-main-row > td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.requests-table .request-band-odd.request-main-row > td:first-child {
    border-left-color: var(--accent);
}

.requests-table .request-linked-row > td {
    border-left-color: #9fb4c4;
    border-bottom: 1px solid #cbd7df;
}

.requests-table .request-work-order-row > td {
    padding-top: 10px;
    padding-bottom: 14px;
}

.requests-table .request-work-order-row p {
    margin: 6px 0 0;
    white-space: pre-wrap;
}

.sort-link {
    color: inherit;
    text-decoration: none;
}

.sort-link:hover,
.sort-link.active {
    color: var(--primary);
}

td p {
    margin: 7px 0 0;
    color: #4b5967;
}

td small {
    display: block;
    margin-top: 4px;
}

.activity-comment-row.request-band-even > td,
.tp-report-row.request-band-even > td,
.evaluation-detail-row.request-band-even > td {
    background: #eef3f6;
}

.activity-comment-row.request-band-odd > td,
.tp-report-row.request-band-odd > td,
.evaluation-detail-row.request-band-odd > td {
    background: #cfe4df;
}

.activity-comments-panel {
    display: grid;
    gap: 12px;
    margin-top: 10px;
}

.activity-comments-details {
    width: 100%;
}

.activity-comment-form {
    width: 100%;
}

.activity-comment-form textarea {
    min-height: 110px;
}

.activity-comments-list {
    display: grid;
    gap: 10px;
}

.activity-comment-card {
    padding: 12px;
    border: 1px solid #cbd7df;
    border-radius: 8px;
    background: white;
}

.activity-comment-card.private-comment {
    border-color: #f1c38e;
    background: #fff8ef;
}

.activity-comment-card p {
    white-space: pre-wrap;
}

.tp-report-panel {
    display: grid;
    gap: 12px;
}

.tp-report-details {
    max-width: 760px;
}

.report-list {
    display: grid;
    gap: 12px;
    margin-top: 10px;
}

.report-card {
    padding: 12px;
    border: 1px solid #cbd7df;
    border-radius: 8px;
    background: white;
}

.report-card p {
    white-space: pre-wrap;
}

.report-files {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.report-files a {
    padding: 6px 9px;
    border-radius: 8px;
    background: #e8eef3;
    color: #1d2a36;
    font-weight: 700;
    text-decoration: none;
}

.report-file-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.report-file-actions button {
    padding: 6px 9px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #eef3f6;
    color: #26323e;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.priority-haute,
.priority-urgente {
    background: #ffe8d6;
    color: #8a4300;
}

.priority-urgente,
.status-annulee {
    background: #fde8e6;
    color: var(--danger);
}

.status-en_cours {
    background: #e5f2ff;
    color: #0f5d91;
}

.status-resolue {
    background: #dff4ea;
    color: #0a6349;
}

.flash {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 8px;
    background: #e2f4ec;
    color: #0a6349;
    border: 1px solid #bde4cf;
}

.flash.error {
    background: #fde8e6;
    color: var(--danger);
    border-color: #f5b8b3;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(17, 24, 32, 0.54);
}

.modal {
    width: min(460px, 100%);
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    box-shadow: 0 28px 80px rgba(17, 24, 32, 0.24);
}

.modal h2 {
    margin: 0 0 10px;
    font-size: 22px;
}

.modal p {
    margin: 0 0 18px;
    color: var(--muted);
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.modal-actions form {
    margin: 0;
}

.cards-list {
    display: grid;
    gap: 12px;
}

.csv-help {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
    color: var(--muted);
    font-size: 14px;
}

.csv-help strong {
    color: var(--text);
}

.csv-help code {
    display: block;
    padding: 9px 10px;
    border-radius: 6px;
    background: #111820;
    color: white;
    overflow-x: auto;
}

.list-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.list-card span,
.list-card p {
    display: block;
    margin: 5px 0 0;
    color: var(--muted);
}

.danger-form {
    margin-top: 12px;
}

.promotion-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.promotion-actions form {
    margin: 0;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.row-actions {
    min-width: 260px;
}

.row-actions summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 750;
}

.inline-form {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.inline-delete {
    margin-top: 10px;
}

.csv-help,
.evaluation-preview {
    margin-top: 12px;
}

.csv-help {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

.evaluation-preview {
    max-width: min(720px, 75vw);
    max-height: 320px;
    overflow: auto;
    white-space: pre-wrap;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafb;
    color: var(--text);
}

.evaluation-grid-form {
    display: grid;
    gap: 12px;
    width: 100%;
}

.evaluation-detail-row:not(.request-linked-row) td {
    background: #eef3f6;
    border-left-color: var(--primary);
    border-top: 1px solid #cbd7df;
    border-bottom: 1px solid #cbd7df;
}

.evaluations-table tbody tr:not(.evaluation-detail-row) > td {
    background: #fff;
    border-top: 1px solid #cbd7df;
    border-bottom: 1px solid #cbd7df;
}

.evaluations-table tbody tr:not(.evaluation-detail-row):nth-child(4n + 3) > td {
    background: #f0f6f4;
}

.evaluations-table tbody tr:not(.evaluation-detail-row) > td:first-child {
    border-left-color: var(--primary);
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.evaluations-table tbody tr:not(.evaluation-detail-row):nth-child(4n + 3) > td:first-child {
    border-left-color: var(--accent);
}

.evaluations-table tbody tr:not(.evaluation-detail-row) > td:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}

.evaluation-name-form {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 260px;
}

.evaluation-name-form input {
    min-width: 180px;
}

.evaluation-grid-wrap {
    max-width: 100%;
    max-height: 520px;
    overflow: auto;
    border: 1px solid #b8c8d5;
    border-radius: 8px;
    background: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.evaluation-grid {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

.evaluation-grid td {
    min-width: 140px;
    padding: 0;
    border: 1px solid var(--line);
}

.evaluation-grid td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 220px;
    background: #fff;
    box-shadow: 1px 0 0 var(--line);
}

.evaluation-grid tr:first-child td:first-child,
.evaluation-grid td:first-child.evaluation-heading-cell {
    background: #e6f0ee;
    z-index: 3;
}

.evaluation-grid input {
    width: 100%;
    min-width: 140px;
    border: 0;
    border-radius: 0;
    padding: 8px 10px;
    background: transparent;
}

.evaluation-heading-cell {
    background: #eef4f3;
    font-weight: 750;
}

.evaluation-grid-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.request-evaluations-panel {
    display: grid;
    gap: 16px;
    padding: 12px;
    border: 1px solid #b8c8d5;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.58);
}

.request-evaluation-form {
    max-width: 520px;
}

.request-evaluation-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid #c2d1dc;
    border-left: 5px solid var(--primary);
    border-radius: 8px;
    background: #fff;
}

.request-evaluation-card h3 {
    margin: 0;
}

.competence-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 20px;
}

.competence-list li {
    color: var(--text);
}

.evaluation-choice-menu {
    display: none;
    position: fixed;
    z-index: 1000;
    max-width: min(720px, calc(100vw - 32px));
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(17, 24, 32, 0.18);
}

.evaluation-choice-menu.open {
    display: grid;
}

.evaluation-choice-menu button {
    border: 0;
    border-radius: 0;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    text-align: left;
    font-weight: 650;
}

.evaluation-choice-menu button:hover {
    background: #eef4f3;
}

.login-page {
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #111820 0%, #263542 55%, #136f63 100%);
}

.login-panel {
    width: min(420px, 100%);
    padding: 28px;
}

.login-brand {
    margin-bottom: 24px;
}

@media (max-width: 980px) {
    body {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    nav {
        grid-auto-flow: column;
        overflow-x: auto;
    }

    .logout {
        margin-top: 0;
        margin-left: auto;
    }

    .metrics,
    .grid.two,
    .filters {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    main,
    .sidebar {
        padding: 18px;
    }

    .topbar {
        display: grid;
    }

    .identity {
        text-align: left;
    }

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