:root {
    --border: #d9dee3;
    --today-bg: #fff8e1;
    --weekend-bg: #f4f5f7;
    --late-color: #c0392b;
    --unscheduled-color: #8a6d00;
    --unscheduled-bg: #fdf3d1;
    --absent-bg: #d8dbe0;
    --absent-color: #4b5563;
}

* { box-sizing: border-box; }

body {
    font-family: "Segoe UI", Arial, sans-serif;
    margin: 0;
    background: #fafbfc;
    color: #1f2937;
}

header#toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

header#toolbar h1 {
    font-size: 18px;
    margin: 0;
    margin-right: auto;
}

#nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

#nav button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
}

#nav button:hover { background: #f0f2f5; }

#range-label {
    font-weight: 600;
    min-width: 220px;
    text-align: center;
}

#status-line {
    font-size: 12px;
    color: #6b7280;
    width: 100%;
}

main { padding: 12px; overflow-x: auto; }

table#grid {
    border-collapse: collapse;
    width: 100%;
    background: #fff;
}

table#grid th, table#grid td {
    border: 1px solid var(--border);
    padding: 4px;
    vertical-align: top;
    font-size: 12px;
}

table#grid th {
    background: #f0f2f5;
    position: sticky;
    top: 0;
    z-index: 1;
}

th.person-col, td.person-col {
    text-align: left;
    min-width: 160px;
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 2;
    font-weight: 600;
}

th.person-col { z-index: 3; }

td.day-cell {
    min-width: 110px;
    height: 64px;
}

td.day-cell.weekend { background: var(--weekend-bg); }

td.day-cell.absent {
    background: repeating-linear-gradient(
        135deg, var(--absent-bg), var(--absent-bg) 6px, #e4e6ea 6px, #e4e6ea 12px
    );
}

td.day-cell.absent .cell-summary {
    color: var(--absent-color);
    font-weight: 600;
    font-style: italic;
}
td.day-cell.today { background: var(--today-bg); }

th.day-col.weekend { background: #e8eaed; }
th.day-col.today { background: #ffe9a8; }

.cell-summary {
    font-size: 10px;
    color: #6b7280;
    margin-bottom: 3px;
    white-space: nowrap;
}

.cell-summary.full { color: #b45309; font-weight: 600; }

.segment {
    border-radius: 3px;
    padding: 3px 5px;
    margin-bottom: 3px;
    font-size: 11px;
    color: #fff;
    cursor: grab;
    user-select: none;
    line-height: 1.3;
}

.segment:active { cursor: grabbing; }

.segment.status-late {
    outline: 2px solid var(--late-color);
    outline-offset: -2px;
    animation: blink-late 1s steps(1, end) infinite;
    color: #fff;
    font-weight: 700;
}

@keyframes blink-late {
    0%, 49% { background: #ef4444; }
    50%, 100% { background: #7f1d1d; }
}

.segment.status-unscheduled {
    background: var(--unscheduled-bg) !important;
    color: var(--unscheduled-color) !important;
    outline: 1px dashed var(--unscheduled-color);
}

/* Livrée l'emporte toujours sur "en retard" (une tâche terminée n'a plus besoin
   d'attirer l'attention, même si elle a fini après son échéance) - !important +
   déclarée après .status-late pour gagner peu importe l'ordre des classes. */
.segment.delivered {
    background: #374151 !important;
    color: #d1d5db !important;
    outline: none !important;
    animation: none !important;
    text-decoration: line-through;
    font-weight: 400;
}

.segment .hours { font-weight: 700; }

.sortable-ghost { opacity: 0.4; }
.sortable-drag { opacity: 0.9; }

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.overlay.hidden { display: none; }

.dialog {
    background: #fff;
    border-radius: 6px;
    padding: 16px 20px;
    max-width: 480px;
    width: 90%;
    max-height: 70vh;
    overflow-y: auto;
}

.dialog p { margin-top: 0; }

.dialog ul { padding-left: 18px; font-size: 13px; color: #374151; }

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.dialog-actions button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    padding: 6px 14px;
    cursor: pointer;
}

.dialog-actions button.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

#actions {
    display: flex;
    gap: 8px;
}

#actions button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
}

#actions button.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.dialog-wide { max-width: 780px; }

.dialog h2, .dialog h3 { margin-top: 0; font-size: 15px; }

.dialog form { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }

.dialog label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: #374151;
}

.dialog label input, .dialog label select {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 6px;
    font-size: 13px;
}

.dialog label.checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.dialog fieldset {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px 10px;
}

.dialog fieldset legend { font-size: 12px; color: #6b7280; padding: 0 4px; }

.hours-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    gap: 6px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.form-row label { min-width: 110px; flex: 1; }

.task-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
}

.task-row select, .task-row input {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 5px 6px;
    font-size: 12px;
    flex: 1 1 110px;
    min-width: 90px;
}

.task-row .task-remove {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    padding: 5px 8px;
}

#project-add-task {
    border: 1px dashed var(--border);
    background: #fff;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 12px;
    align-self: flex-start;
}

.unscheduled-banner {
    background: var(--unscheduled-bg);
    border: 1px solid var(--unscheduled-color);
    color: var(--unscheduled-color);
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.unscheduled-banner.hidden { display: none; }

.unscheduled-banner strong { display: block; margin-bottom: 4px; }

.unscheduled-banner ul { margin: 0; padding-left: 18px; }

.no-estimate-banner {
    background: #eaf2fd;
    border: 1px solid #2563eb;
    color: #1e40af;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.no-estimate-banner.hidden { display: none; }

.no-estimate-banner strong { display: block; margin-bottom: 4px; }

.no-estimate-banner ul { margin: 0; padding-left: 18px; }

.overdue-planned-banner {
    background: #fff4e5;
    border: 1px solid #d97706;
    color: #92400e;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.overdue-planned-banner.hidden { display: none; }

.overdue-planned-banner strong { display: block; margin-bottom: 2px; }

.overdue-planned-banner p { margin: 0 0 6px; font-size: 12px; }

.overdue-planned-banner ul { margin: 0; padding-left: 18px; }

.overdue-planned-banner li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.overdue-planned-banner li.report-alert { color: #b91c1c; font-weight: 600; }

.overdue-planned-banner button {
    border: 1px solid #d97706;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 8px;
    font-size: 12px;
    flex-shrink: 0;
}

.task-details {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    font-size: 13px;
    margin: 0;
}

.task-details dt { color: #6b7280; }
.task-details dd { margin: 0; font-weight: 600; }

.task-chaining-field { margin-top: 10px; max-width: 200px; }

.absence-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

.absence-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.absence-list .absence-delete {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    padding: 3px 8px;
    font-size: 12px;
    flex-shrink: 0;
}

.absence-list .absence-empty { color: #6b7280; font-size: 13px; padding: 6px 0; }

.dialog-hint { color: #6b7280; font-size: 12px; margin: -4px 0 4px; }

.person-card { border-bottom: 1px solid var(--border); }

.person-card-header {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px 4px;
    font-weight: 600;
    font-size: 13px;
    color: inherit;
}

.person-card-header:hover { background: #f9fafb; }

.person-card-details {
    padding: 4px 4px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.person-card-details.hidden { display: none; }

.person-card-details .throughput-field {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
}

.person-card-details .throughput-field input {
    width: 70px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 12px;
}

.person-card-details .person-save {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    padding: 4px 10px;
    font-size: 12px;
    align-self: flex-start;
}

.person-card-details .person-save.saved { border-color: #16a34a; color: #16a34a; }

#protemos-report, #memoq-report { margin-top: 12px; font-size: 13px; }

#protemos-report .protemos-stats, #memoq-report .protemos-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 6px 12px;
    margin-bottom: 10px;
}

#protemos-report .protemos-stats div, #memoq-report .protemos-stats div {
    background: #f0f2f5;
    border-radius: 4px;
    padding: 6px 8px;
}

#protemos-report .protemos-error, #memoq-report .protemos-error {
    color: var(--late-color);
    background: var(--unscheduled-bg);
    border: 1px solid var(--late-color);
    border-radius: 4px;
    padding: 8px;
}

#protemos-report ul, #memoq-report ul { max-height: 180px; overflow-y: auto; padding-left: 18px; color: #374151; }
