/* ─── Page Grille de saisie ─────────────────────────────────────────── */

.gr-toolbar {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: 46px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  z-index: 50;
}

.gr-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-1);
  font-size: 13px;
}

.gr-week-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.gr-nav-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-1);
  font-size: 13px;
  cursor: pointer;
  font-weight: 600;
}
.gr-nav-btn:hover { background: var(--surface); }

.gr-date-input {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-1);
  font-size: 13px;
}

.gr-legend {
  display: flex;
  gap: 12px;
  margin-left: 8px;
}
.gr-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-2);
}
.gr-legend-chip {
  width: 22px;
  height: 11px;
  border-radius: 2px;
  flex-shrink: 0;
}

.gr-pending {
  font-size: 12px;
  color: #e65100;
  font-weight: 600;
  margin-left: auto;
}

/* ── Corps principal ── */
.gr-body {
  margin-top: calc(var(--header-h) + 46px);
  height: calc(100vh - var(--header-h) - 46px);
  overflow: auto;
}

.gr-grid-wrap {
  padding: 16px;
  display: inline-block;
  min-width: 100%;
}

/* ── Table ── */
.gr-table {
  border-collapse: collapse;
  table-layout: fixed;
  width: max-content;
  min-width: 860px;
}

.gr-table thead th {
  background: #1a237e;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  padding: 8px 6px;
  text-align: center;
  border: 1px solid #253380;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
  line-height: 1.4;
  width: 100px;
}
.gr-table thead th:first-child {
  width: 160px;
  text-align: left;
  padding-left: 12px;
  position: sticky;
  left: 0;
  z-index: 6;
}
.gr-table thead th.we { background: #0d1870; }

.gr-table tbody td {
  border: 1px solid var(--border);
  padding: 3px 4px;
  vertical-align: top;
  min-height: 48px;
  cursor: pointer;
  position: relative;
  width: 100px;
}
.gr-table tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  border-right: 2px solid var(--border);
  cursor: default;
  padding: 0;
  width: 160px;
}
.gr-table tbody tr:nth-child(even) td:first-child { background: var(--bg); }
.gr-table tbody td.we { background: rgba(26,35,126,.04); }
.gr-table tbody td:not(:first-child):hover { background: #e8eaf6; outline: 2px solid #1a237e; outline-offset: -2px; }

/* Cellule employé */
.gr-emp-cell {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  height: 100%;
}
.gr-emp-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.gr-emp-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.3;
}
.gr-emp-svc {
  font-size: 10px;
  color: var(--text-2);
  font-weight: 400;
}

/* Chips dans les cellules */
.gr-cell-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 42px;
}
.gr-chip {
  border-radius: 3px;
  padding: 2px 5px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}
.gr-chip-work { color: #fff; }
.gr-chip-repos {
  border: 2px solid;
  background: transparent;
  justify-content: center;
  font-size: 11px;
  padding: 2px 4px;
}
.gr-chip-j1 {
  font-size: 8px;
  background: rgba(255,255,255,0.3);
  border-radius: 2px;
  padding: 0 3px;
}
.gr-cell-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #9fa8da;
  opacity: 0;
  transition: opacity .12s;
  pointer-events: none;
}
.gr-table tbody td:not(:first-child):hover .gr-cell-hint { opacity: 1; }
.gr-table tbody td:not(:first-child):hover .gr-cell-inner { opacity: .4; }

/* ── Popover ── */
.gr-popover {
  position: fixed;
  z-index: 200;
  width: 270px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  padding: 14px;
}

.gr-pop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.gr-pop-title {
  font-size: 12px;
  font-weight: 700;
  color: #1a237e;
  line-height: 1.3;
}
.gr-pop-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-2);
  padding: 0;
  line-height: 1;
}

/* Événements existants */
.gr-pop-evts {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gr-pop-evt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.gr-pop-evt-label {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
}
.gr-pop-evt-del {
  background: none;
  border: none;
  cursor: pointer;
  color: #e57373;
  font-size: 15px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
.gr-pop-evt-del:hover { color: #c62828; }

/* Tabs */
.gr-pop-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.gr-pop-tab {
  flex: 1;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.gr-pop-tab.active {
  background: #e8eaf6;
  border-color: #1a237e;
  color: #1a237e;
}

.gr-pop-panel { display: flex; flex-direction: column; gap: 8px; }
.gr-pop-panel.hidden { display: none; }

/* Présets */
.gr-pop-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.gr-preset {
  font-size: 11px;
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  background: var(--bg);
  color: var(--text-1);
  white-space: nowrap;
}
.gr-preset:hover { background: #e8eaf6; border-color: #1a237e; color: #1a237e; }

/* Horaires */
.gr-pop-times {
  display: flex;
  align-items: flex-end;
  gap: 6px;
}
.gr-pop-sep {
  font-size: 14px;
  color: var(--text-2);
  padding-bottom: 6px;
}
.gr-pop-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.gr-pop-field label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.gr-pop-field input[type=time],
.gr-pop-field select {
  padding: 5px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text-1);
  font-size: 12px;
  width: 100%;
}

.gr-pop-add-btn {
  width: 100%;
  padding: 7px;
  background: #1a237e;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
}
.gr-pop-add-btn:hover { background: #283593; }

/* Repos grid */
.gr-repos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.gr-repos-btn {
  padding: 8px 6px;
  border-radius: 7px;
  border: 2px solid;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  letter-spacing: .04em;
  transition: background .1s;
}
.gr-repos-btn:hover { background: rgba(0,0,0,.06); }

/* Overlay */
.gr-overlay {
  position: fixed;
  inset: 0;
  z-index: 199;
}

/* ── Copier semaine modal ── */
.gr-copy-info {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 8px;
}

@media print { .gr-toolbar, .page-header { display: none; } }
