:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e6e9f2;
  --text: #1a2233;
  --text-muted: #6b7488;
  --primary: #2f6fd6;
  --primary-dark: #244f9e;
  --danger: #d64545;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.06), 0 8px 24px rgba(20, 30, 60, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 16px; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: #151b2e;
  color: #cbd3ea;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 20px 0;
}
.sidebar-logo {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  padding: 0 20px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; }
.sidebar-nav a {
  color: #aeb7d1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }

.sidebar-footer { padding: 12px 20px 0; border-top: 1px solid rgba(255,255,255,0.08); margin-top: 12px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding-top: 14px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.user-name { color: #fff; font-weight: 600; font-size: 13px; }
.logout-link { font-size: 12px; color: #8b96b8; }
.logout-link:hover { color: #fff; }

.main-content { flex: 1; padding: 28px 32px; max-width: 1400px; }

.page-header {
  display: flex; justify-content: space-between; align-items: flex-end;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-subtitle { color: var(--text-muted); margin: 0; font-size: 13px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all 0.15s;
  background: var(--surface);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fdeceb; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Cards / forms ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-row--split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { font-weight: 600; font-size: 12.5px; color: var(--text-muted); }
input[type="text"], input[type="password"], input[type="date"], input[type="time"], textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; background: #fbfcfe; color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
textarea { resize: vertical; }

.muted { color: var(--text-muted); }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; }
.alert-success { background: #e5f7ec; color: #17753a; }
.alert-error { background: #fbe7e7; color: #a72a2a; }

.empty-state {
  text-align: center; padding: 60px 20px; background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ---------- Auth pages ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
  width: 360px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px; text-align: center;
}
.auth-logo { font-size: 34px; margin-bottom: 8px; }
.auth-subtitle { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }
.auth-form { text-align: left; display: flex; flex-direction: column; gap: 4px; }
.auth-form .btn { margin-top: 12px; }

/* ---------- Legend ---------- */
.legend { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.week-nav { display: flex; gap: 8px; }

/* ---------- Planning table ---------- */
.table-wrapper {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; box-shadow: var(--shadow);
}
.planning-table { border-collapse: collapse; width: 100%; min-width: 820px; }
.planning-table th, .planning-table td { border-bottom: 1px solid var(--border); padding: 8px; text-align: center; }
.planning-table thead th {
  background: #fafbfd; font-size: 12px; color: var(--text-muted); font-weight: 700;
  padding: 12px 8px; border-bottom: 2px solid var(--border);
}
.planning-table thead th.is-today { color: var(--primary); }
.day-date { font-weight: 400; font-size: 11px; }
.employee-col { text-align: left !important; min-width: 170px; padding-left: 16px !important; }
.employee-name { font-weight: 600; }
.employee-role { font-size: 11.5px; color: var(--text-muted); }
td.is-today { background: #f5f8ff; }

.cell { padding: 6px !important; }
.cell-btn {
  width: 100%; min-height: 52px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fafbfd; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  transition: transform 0.1s, box-shadow 0.1s; position: relative;
}
.cell-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(20,30,60,0.10); }
.cell-icon { font-size: 15px; line-height: 1; }
.cell-empty { font-size: 16px; color: #c3c9d9; }
.note-dot {
  position: absolute; top: 5px; right: 6px; width: 6px; height: 6px;
  border-radius: 50%; background: currentColor; opacity: 0.7;
}

/* ---------- Person list ---------- */
.person-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.person-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.person-actions { display: flex; gap: 8px; }

.stack-form { display: flex; flex-direction: column; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,20,35,0.45);
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal form { padding: 18px 20px; }

.status-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-choice {
  border: 1.5px solid var(--border); background: #fff; border-radius: var(--radius-sm);
  padding: 10px; font-weight: 600; font-size: 13px; cursor: pointer; text-align: left;
  display: flex; align-items: center; gap: 8px; color: var(--text);
}
.status-choice:hover { border-color: var(--sc, var(--primary)); }
.status-choice.selected { background: var(--sb, #eef3fd); border-color: var(--sc, var(--primary)); color: var(--sc, var(--primary)); }
.status-choice--clear { grid-column: 1 / -1; justify-content: center; color: var(--text-muted); }

.modal-meta { font-size: 11.5px; color: var(--text-muted); margin: 4px 0 14px; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.form-error { color: var(--danger); font-size: 12.5px; margin-top: 10px; }
/* Toolbar & Navigation Date */
.planning-toolbar { margin-bottom: 20px; }
.date-nav { display: flex; gap: 8px; margin-bottom: 10px; }
.date-picker-form { display: flex; align-items: center; gap: 12px; }

/* Grille Horaires */
.planning-container {
  border: 2px solid #666;
  background: #fff;
  padding: 10px;
}
.planning-title {
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 10px;
}
.planning-table-daily {
  width: 100%;
  border-collapse: collapse;
}
.planning-table-daily th, 
.planning-table-daily td {
  border: 1px solid #333;
  padding: 10px;
  text-align: center;
}
.col-technician {
  text-align: left;
  font-size: 1.5rem;
  font-weight: bold;
  width: 200px;
}
.col-technician-name {
  text-align: left;
  font-weight: bold;
  background: #f9f9f9;
}
.time-slot {
  height: 40px;
  min-width: 60px;
  position: relative;
}
