/* ============ TOKENS ============ */
:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eaf1ff;

  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --border: #ececee;
  --border-strong: #e2e2e5;

  --text: #17181c;
  --text-dim: #6b6d76;
  --text-faint: #9a9ba3;

  --green: #16a34a;
  --green-soft: #eafcf1;
  --blue: #2563eb;
  --amber: #d97706;
  --amber-soft: #fff7e6;
  --violet: #8b5cf6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20,20,30,0.04), 0 1px 1px rgba(20,20,30,0.03);
  --shadow-md: 0 4px 14px rgba(20,20,30,0.06);
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

[data-theme="dark"] {
  --bg: #0f0f12;
  --surface: #17181c;
  --surface-2: #1c1d22;
  --border: #26272d;
  --border-strong: #303138;

  --text: #f3f3f5;
  --text-dim: #a3a4ad;
  --text-faint: #6c6d76;

  --accent-soft: #12203a;
  --green-soft: #0f2419;
  --amber-soft: #2a2110;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ THEME TOGGLE ============ */
.theme-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 120;
  box-shadow: var(--shadow);
  transition: background var(--transition), color var(--transition), border var(--transition), box-shadow var(--transition);
}
.theme-toggle:hover {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-md);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }
[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* ============ CONTENT ============ */
.content { padding: 22px 24px 60px; max-width: 1600px; width: 100%; margin: 0 auto; }

.page-header {
  margin-bottom: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}
.page-title { font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.01em; }
.page-sub { font-size: 13.5px; color: var(--text-dim); margin: 0; }

/* Filter bar */
.filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header .filter-bar { margin-bottom: 0; }
.page-header .header-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition), border var(--transition), color var(--transition);
  display: flex; align-items: center; gap: 7px;
}
.filter-btn:hover { background: var(--surface-2); }
.filter-btn.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.filter-label { font-size: 12.5px; font-weight: 600; color: var(--text-faint); margin-right: 2px; }

/* Toast */
.edt-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 12px);
  background: var(--text);
  color: var(--surface);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), transform var(--transition);
  z-index: 200;
}
.edt-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Stat cards grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 15px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.stat-label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.stat-icon {
  width: 30px; height: 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.stat-icon svg { width: 16px; height: 16px; }
.stat-icon svg,
.icon-btn svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14.5px; font-weight: 700; margin-bottom: 16px;
}

/* Simple horizontal bar list (Charge par jour) */
.hbar-row { margin-bottom: 12px; }
.hbar-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.hbar-track { height: 7px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 4px; }

/* ============ EMPLOI DU TEMPS ============ */
.tt-card { padding: 0; overflow: hidden; }

.tt-scroll { overflow-x: auto; }
.tt-scroll::-webkit-scrollbar { height: 8px; }
.tt-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.tt-grid { min-width: 940px; }

.tt-head-row {
  display: grid;
  grid-template-columns: 62px repeat(6, 1fr);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 3;
  background: var(--surface);
}
.tt-head-cell {
  padding: 11px 10px;
  text-align: center;
  border-left: 1px solid var(--border);
}
.tt-head-cell:first-child { border-left: none; }
.tt-day { font-size: 13px; font-weight: 700; }
.tt-date { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.tt-head-cell.today { background: var(--accent-soft); }
.tt-head-cell.today .tt-day { color: var(--accent-dark); }
.tt-head-cell.today .tt-date { color: var(--accent-dark); opacity: 0.8; }
.tt-now-chip {
  display: inline-block;
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.tt-body {
  display: grid;
  grid-template-columns: 62px repeat(6, 1fr);
  position: relative;
}
.tt-hours { border-right: 1px solid var(--border); }
.tt-hour {
  height: 23px;
  font-size: 10.5px;
  color: var(--text-dim);
  text-align: right;
  padding: 0 8px;
  transform: translateY(-6px);
}
.tt-hour.half {
  font-size: 9px;
  color: var(--text-faint);
  opacity: 0.7;
}
.tt-col {
  position: relative;
  border-left: 1px solid var(--border);
  background-image:
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 45px,
      var(--border-strong) 45px,
      var(--border-strong) 46px
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 22px,
      var(--border) 22px,
      var(--border) 23px
    );
}
.tt-col:first-of-type { border-left: none; }
.tt-col.today { background-color: color-mix(in srgb, var(--accent) 5%, transparent); }
.tt-now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 2;
  pointer-events: none;
  box-shadow: 0 0 5px color-mix(in srgb, var(--accent) 55%, transparent);
}
.tt-now-line::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.tt-now-tip {
  position: absolute;
  left: 6px;
  top: -12px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tt-shift {
  position: absolute;
  border-radius: 7px;
  border: 1px solid var(--s);
  border-left: 3px solid var(--s);
  background: color-mix(in srgb, var(--s) 13%, var(--surface));
  padding: 5px 7px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: box-shadow var(--transition), transform var(--transition);
}
.tt-shift:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); z-index: 4; }
.tt-shift-time { font-size: 9px; font-weight: 700; color: var(--s); }
.tt-shift-name { font-size: 10.5px; font-weight: 600; color: var(--text); margin-top: 0; line-height: 1.2; }
.tt-shift-role { font-size: 9px; color: var(--text-dim); margin-top: 0; }
.tt-shift.dim { opacity: 0.22; }

.tt-foot {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.tt-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.tt-legend-dot { width: 9px; height: 9px; border-radius: 3px; }
.tt-foot-hint { font-size: 12px; color: var(--text-faint); font-style: italic; margin-left: auto; }

/* Staff hour summary */
.tt-side { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.tt-side .card { min-width: 0; }
.tt-person {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
}
.tt-person:last-child { border-bottom: none; }
.tt-person-info { flex: 1; min-width: 0; }
.tt-person-av {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.tt-person-name { font-size: 13px; font-weight: 600; }
.tt-person-role { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.tt-person-hours { margin-left: auto; text-align: right; }
.tt-person-h { font-size: 13px; font-weight: 700; }
.tt-person-shifts { font-size: 11px; color: var(--text-faint); }

/* Modal */
.tm-row { display: flex; justify-content: space-between; font-size: 13px; padding: 6px 0; }
.tm-row span:first-child { color: var(--text-dim); }
.tm-row span:last-child { font-weight: 600; }
.table-modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,18,0.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.table-modal-backdrop.open { display: flex; }
.table-modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%; max-width: 340px;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.tm-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.tm-title { font-size: 16px; font-weight: 700; }
.tm-sub { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-faint); margin-top: 3px; }
.tm-items { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 10px 0; margin-bottom: 12px; }
.tm-footer { display: flex; align-items: center; justify-content: space-between; }
.tm-amount { font-size: 16px; font-weight: 700; }
.tm-open-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12.5px; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-sm);
  cursor: pointer; font-family: inherit;
  text-decoration: none;
}
.tm-open-btn:hover { background: var(--accent-soft); color: var(--accent-dark); }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* Footer */
.page-footer {
  margin-top: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12.5px;
  color: var(--text-faint);
}
.page-footer a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.page-footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 1000px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .tt-side { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .content { padding: 16px 14px 45px; }
}
