:root {
    --primary: #69BFBA;
    --primary-dark: #4a9e99;
    --primary-light: #e0f2f1;
    --bg: #f5f5f5;
    --bg-white: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --header-bg: #2d3748;
    --success: #48bb78;
    --warning: #ed8936;
    --danger: #f56565;
    --border: #e2e8f0;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.header {
    background: var(--header-bg);
    color: white;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.header img { height: 44px; }
.header .user-name { color: var(--primary); font-weight: 500; margin-right: auto; }
.header nav { display: flex; gap: 1rem; align-items: center; }
.header a { color: rgba(255,255,255,0.8); text-decoration: none; font-size: 0.9rem; }
.header a:hover { color: var(--primary); }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.25rem; margin-bottom: 0.75rem; }

.month-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.month-nav a {
    color: var(--primary-dark);
    text-decoration: none;
    font-size: 1.2rem;
    padding: 0.25rem 0.5rem;
}
.month-nav a:hover { background: var(--primary-light); border-radius: 4px; }
.month-nav .current { font-size: 1.1rem; font-weight: 600; }

.grid-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.grid-table th {
    background: var(--header-bg);
    color: white;
    padding: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
}
.grid-table td {
    padding: 0.25rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.grid-table tr:hover { background: var(--primary-light); }
.grid-table .date-cell {
    text-align: left;
    padding-left: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    min-width: 100px;
}

.cell-input {
    width: 50px;
    text-align: center;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 0.25rem;
    font-size: 0.85rem;
    background: transparent;
}
.cell-input:focus {
    border-color: var(--primary);
    outline: none;
    background: white;
}

.total-ok { color: var(--success); font-weight: 600; }
.total-partial { color: var(--warning); font-weight: 600; }
.total-over { color: var(--danger); font-weight: 600; }
.total-empty { color: var(--text-light); }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #e53e3e; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.25rem; font-size: 0.9rem; }
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
}
.form-group input:focus, .form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.card {
    background: var(--bg-white);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 0.5rem;
    vertical-align: middle;
}

/* Color palette picker */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0;
}
.cp-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.1s;
}
.cp-swatch:hover {
    transform: scale(1.15);
    border-color: var(--text-light);
}
.cp-swatch.cp-selected {
    border-color: var(--text);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text);
}

/* Drag & drop project list */
.dnd-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 1rem;
}
.dnd-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: box-shadow 0.15s, opacity 0.15s;
}
.dnd-item:hover { box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
.dnd-item.dnd-inactive { opacity: 0.5; }
.dnd-item.dnd-dragging { opacity: 0.4; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.dnd-handle {
    cursor: grab;
    font-size: 1.1rem;
    color: var(--text-light);
    user-select: none;
    padding: 0 0.25rem;
}
.dnd-handle:active { cursor: grabbing; }
.dnd-name { font-weight: 600; min-width: 120px; }
.dnd-desc { flex: 1; color: var(--text-light); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dnd-status { font-size: 0.8rem; color: var(--text-light); min-width: 50px; }
.dnd-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.dnd-save-status {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    min-height: 1.2em;
}
.dnd-save-ok { color: var(--success); }
.dnd-save-err { color: var(--danger); }

@media (max-width: 768px) {
    .dnd-item { flex-wrap: wrap; }
    .dnd-desc { display: none; }
    .dnd-actions { width: 100%; justify-content: flex-end; }
}

.alert-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.alert-missing { color: var(--danger); }
.alert-partial { color: var(--warning); }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th { text-align: left; padding: 0.5rem; border-bottom: 2px solid var(--border); font-size: 0.85rem; }
.admin-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--header-bg);
}
.login-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.login-card img { height: 48px; margin-bottom: 1.5rem; }
.login-card h1 { font-size: 1.25rem; margin-bottom: 1rem; }

@media (max-width: 768px) {
    .header { flex-wrap: wrap; padding: 0.5rem 1rem; }
    .container { padding: 1rem; }
    .grid-table { font-size: 0.75rem; }
    .cell-input { width: 40px; font-size: 0.75rem; }
    .grid-table th { font-size: 0.7rem; padding: 0.3rem; }
}

/* ===== Saisie v2: Calendar + Day Panel ===== */

.saisie-container {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

/* -- Calendar Zone -- */
.saisie-calendar {
    width: 300px;
    min-width: 300px;
    background: var(--bg-white);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.cal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}
.cal-nav-btn {
    color: var(--primary-dark);
    text-decoration: none;
    font-size: 1.3rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    line-height: 1;
}
.cal-nav-btn:hover { background: var(--primary-light); }
.cal-title {
    font-weight: 600;
    font-size: 1rem;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-header {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    padding: 0.25rem 0;
    text-transform: uppercase;
}

.cal-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border-radius: 6px;
    position: relative;
    transition: transform 0.1s;
}

.cal-blank {
    background: transparent;
}

.cal-nonworking {
    background: #a0aec0;
    color: #718096;
    text-decoration: line-through;
    cursor: default;
}

.cal-complete {
    background: #48bb78;
    color: white;
    font-weight: 500;
}

.cal-partial {
    background: #ed8936;
    color: white;
    font-weight: 500;
}

.cal-over {
    background: #f56565;
    color: white;
    font-weight: 500;
}

.cal-empty {
    background: #e2e8f0;
    color: var(--text);
}

.cal-clickable {
    cursor: pointer;
}
.cal-clickable:hover {
    transform: scale(1.1);
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.cal-selected {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    z-index: 3;
}

.cal-today {
    font-weight: 700;
}

.cal-legend {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    color: var(--text-light);
}
.cal-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* -- Tooltip -- */
.cal-tooltip {
    display: none;
    position: fixed;
    z-index: 100;
    background: var(--header-bg);
    color: white;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    min-width: 160px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    pointer-events: none;
}
.tip-bar {
    display: flex;
    height: 12px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.35rem;
}
.tip-seg {
    height: 100%;
    min-width: 2px;
}
.tip-seg-empty {
    background: rgba(255,255,255,0.2);
}
.tip-total {
    font-size: 0.75rem;
    text-align: center;
}

/* -- Day Panel -- */
.saisie-panel {
    flex: 1;
    background: var(--bg-white);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    min-width: 0;
}

.panel-header {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: capitalize;
    color: var(--header-bg);
}

/* Stacked progress bar */
.panel-bar-container {
    margin-bottom: 1.25rem;
}

.stacked-bar {
    display: flex;
    width: 100%;
    height: 24px;
    border-radius: 8px;
    overflow: hidden;
    background: #e2e8f0;
}

.stacked-bar.bar-over {
    background: var(--danger);
    animation: bar-pulse 1s ease-in-out infinite;
}

@keyframes bar-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245,101,101,0.4); }
    50% { box-shadow: 0 0 0 4px rgba(245,101,101,0); }
}

.bar-seg {
    height: 100%;
    transition: width 0.15s ease;
    min-width: 0;
}
.bar-seg-empty {
    background: #e2e8f0;
}

/* Project rows */
.panel-projects {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1rem;
}

.proj-row {
    display: contents;
}

.proj-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.proj-name {
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.proj-slider-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex: 1;
    min-width: 0;
}

.proj-value {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 36px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.proj-num-input {
    width: 60px;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.25rem 0.3rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    background: transparent;
    -moz-appearance: textfield;
}
.proj-num-input::-webkit-outer-spin-button,
.proj-num-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.proj-num-input:focus {
    border-color: var(--primary);
    outline: none;
    background: white;
}

/* Range slider styling */
.proj-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    background: #e2e8f0;
}

.proj-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--project-color, var(--primary));
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.1s;
}
.proj-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.proj-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--project-color, var(--primary));
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.proj-slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
}

/* Total row */
.panel-total {
    font-size: 1.05rem;
    font-weight: 700;
    padding: 0.75rem 0;
    border-top: 2px solid var(--border);
    text-align: right;
    color: var(--text-light);
}
.panel-total.total-complete { color: var(--success); }
.panel-total.total-partial { color: var(--warning); }
.panel-total.total-over { color: var(--danger); }

/* Save indicator */
.save-indicator {
    text-align: right;
    font-size: 0.8rem;
    color: var(--success);
    min-height: 1.2em;
    transition: opacity 0.3s;
}
.save-flash {
    animation: flash-in 0.3s ease;
}
@keyframes flash-in {
    0% { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* -- Responsive -- */
@media (max-width: 768px) {
    .saisie-container {
        flex-direction: column;
    }
    .saisie-calendar {
        width: 100%;
        min-width: unset;
    }
    .proj-label {
        min-width: 100px;
    }
    .proj-name {
        max-width: 100px;
    }
}
