/* ============================================================
   BDCOM Suivi des Heures — Styles v3
   ============================================================ */

/* ── Thème (dark par défaut, light via data-theme ou prefers-color-scheme) ── */
:root {
  --bg: #0b0d12;
  --surface: #13161e;
  --surface2: #1a1f2c;
  --surface3: #232838;
  --border: #252b3b;
  --border2: #2e3649;
  --accent: #f97316;
  --accent2: #fb923c;
  --blue: #3b82f6;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --purple: #a78bfa;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light theme — couleurs appliquées soit via data-theme="light",
   soit quand data-theme="auto" (ou absent) ET prefers-color-scheme: light */
:root[data-theme="light"],
:root[data-theme="auto"] {
  /* placeholder — recouvert par le media query ci-dessous si auto */
}

:root[data-theme="light"] {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --surface3: #f1f5f9;
  --border: #e2e8f0;
  --border2: #cbd5e1;
  --accent: #ea6c0a;
  --accent2: #f97316;
  --blue: #2563eb;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --purple: #7c3aed;
  --text: #0f172a;
  --text2: #475569;
  --text3: #94a3b8;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.15);
}
:root[data-theme="light"] select option {
  background: #fff;
  color: #0f172a;
}

/* Auto : suit le système uniquement s'il est en light */
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"],
  :root:not([data-theme]) {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --surface3: #f1f5f9;
    --border: #e2e8f0;
    --border2: #cbd5e1;
    --accent: #ea6c0a;
    --accent2: #f97316;
    --blue: #2563eb;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #ca8a04;
    --purple: #7c3aed;
    --text: #0f172a;
    --text2: #475569;
    --text3: #94a3b8;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.15);
  }
  :root[data-theme="auto"] select option,
  :root:not([data-theme]) select option {
    background: #fff;
    color: #0f172a;
  }
}

/* ── Reset ── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
::selection {
  background: var(--accent);
  color: #000;
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 3px;
}

/* ── Forms ── */
input,
select,
textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  width: 100%;
  transition: border-color var(--transition), background var(--transition);
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
input::placeholder,
textarea::placeholder {
  color: var(--text3);
}
select option {
  background: var(--surface2);
}

/* ── Buttons ── */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-weight: 500;
  transition: all var(--transition);
  user-select: none;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--accent);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
}
.btn-success {
  background: rgba(34, 197, 94, 0.12);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.btn-success:hover:not(:disabled) {
  background: rgba(34, 197, 94, 0.2);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}
.btn-icon {
  padding: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Loader ── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: var(--text3);
}

/* ── Screens ── */
.screen {
  display: none;
  height: 100vh;
  overflow: hidden;
}
.screen.active {
  display: flex;
}

/* ── Login ── */
#screen-login {
  align-items: center;
  justify-content: center;
  background: var(--bg);
  position: relative;
  padding: 20px;
}
#screen-login::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(249, 115, 22, 0.12), transparent);
  pointer-events: none;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
  text-align: center;
}
.login-logo-img {
  max-width: 240px;
  width: 100%;
  height: auto;
  margin: 0 auto 28px;
  display: block;
  background: #ffffff;
  padding: 16px;
  border-radius: 12px;
}
:root[data-theme="light"] .login-logo-img {
  background: transparent;
  padding: 0;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .login-logo-img,
  :root:not([data-theme]) .login-logo-img {
    background: transparent;
    padding: 0;
  }
}
.sidebar-logo-img {
  max-width: 160px;
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  justify-content: center;
}
.login-logo-icon {
  width: 48px;
  height: 48px;
  background: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}
.login-logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.login-logo-text span {
  color: var(--accent);
}
.login-title {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-sub {
  color: var(--text2);
  margin-bottom: 28px;
  font-size: 13px;
}
.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: left;
}
.btn-microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}
.btn-microsoft:hover {
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.05);
}
.btn-microsoft svg {
  width: 22px;
  height: 22px;
}

/* ── App shell ── */
#screen-app {
  flex-direction: row;
}

/* Mobile bar */
.mobile-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 50;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mobile-bar img {
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
}
:root[data-theme="light"] .mobile-bar img {
  background: transparent;
  padding: 0;
}
.mobile-bar-title {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 16px;
}
.mobile-bar-title span {
  color: var(--accent);
}
.burger-btn {
  background: none;
  border: none;
  color: var(--text);
  padding: 8px;
  display: flex;
  align-items: center;
}
.burger-btn svg {
  width: 24px;
  height: 24px;
}

/* Sidebar */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
}
.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}
.sidebar-logo-text {
  font-family: 'Syne', sans-serif;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.sidebar-logo-text span {
  color: var(--accent);
}
.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #000;
  flex-shrink: 0;
}
.sidebar-user-name {
  font-weight: 600;
  font-size: 13px;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--text3);
  text-transform: capitalize;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}
.nav-section {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  font-weight: 500;
  user-select: none;
}
.nav-item:hover {
  background: var(--surface2);
  color: var(--text);
}
.nav-item.active {
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent);
}
.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.sidebar-bottom {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

/* Main */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.main-header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  flex-shrink: 0;
}
.main-header h1 {
  font-family: 'Syne', sans-serif;
  font-size: 20px;
  font-weight: 700;
  flex: 1;
}
.main-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  animation: fadeIn 200ms ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ── Banners ── */
.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 13px;
}
.banner-warning {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  color: var(--yellow);
}
.banner-info {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  color: var(--blue);
}
.banner-danger {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--red);
}
.banner a {
  color: inherit;
  text-decoration: underline;
}

/* ── Stats cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color var(--transition);
}
.stat-card:hover {
  border-color: var(--border2);
}
.stat-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 6px;
}
.stat-value {
  font-family: 'DM Mono', monospace;
  font-size: 22px;
  font-weight: 500;
}
.stat-value.accent { color: var(--accent); }
.stat-value.blue { color: var(--blue); }
.stat-value.green { color: var(--green); }
.stat-value.yellow { color: var(--yellow); }
.stat-value.purple { color: var(--purple); }
.stat-value small {
  font-size: 12px;
  color: var(--text2);
  margin-left: 2px;
}

/* ── Month nav ── */
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.month-nav span {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
  min-width: 180px;
  text-align: center;
  letter-spacing: -0.3px;
}
.month-nav button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text2);
  padding: 0;
}
.month-nav button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Status badge ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.status-brouillon { background: var(--surface2); color: var(--text3); border: 1px solid var(--border); }
.status-soumis { background: rgba(59, 130, 246, 0.12); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.3); }
.status-valide { background: rgba(34, 197, 94, 0.12); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.3); }
.status-rejete { background: rgba(239, 68, 68, 0.12); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.3); }

/* ── Calendar ── */
.day-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 4px;
}
.day-grid-header span {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0;
}
.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 90px;
  gap: 6px;
}
.day-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 7px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 74px;
  max-height: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}
.day-cell:hover:not(.locked) {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.day-cell.weekend {
  opacity: 0.4;
}
.day-cell.has-entry {
  border-color: var(--border2);
}
.day-cell.today {
  border-color: rgba(249, 115, 22, 0.5);
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.2);
}
.day-cell.locked {
  opacity: 0.65;
  cursor: not-allowed;
}
.day-indicator {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}
.ind-green { background: var(--green); }
.ind-orange { background: var(--accent); }
.ind-gray { background: var(--border2); }
.ind-blue { background: var(--blue); }
.ind-purple { background: var(--purple); }
.ind-red { background: var(--red); }
.day-num {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}
.day-summary {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.day-chantier {
  font-size: 10px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-chantier strong {
  color: var(--text);
  font-weight: 600;
}
.day-tags {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: auto;
}
.tag {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'DM Mono', monospace;
  white-space: nowrap;
}
.tag-hours { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.tag-supp { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }
.tag-night { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.tag-trajet { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.tag-gd { background: rgba(249, 115, 22, 0.15); color: var(--accent); }
.tag-panier { background: rgba(168, 85, 247, 0.12); color: #c084fc; }
.day-add {
  color: var(--text3);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: center;
  flex: 1;
  opacity: 0;
  transition: opacity var(--transition);
}
.day-add svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.day-cell:hover .day-add {
  color: var(--accent);
  opacity: 1;
}

/* Recent affaire pills */
.recent-nums {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.num-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: 'DM Mono', monospace;
}
.num-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(249, 115, 22, 0.08);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.active {
  display: flex;
  animation: overlayIn 150ms ease-out;
}
@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 740px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: none; }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.modal-header h2 {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 700;
  flex: 1;
}
.modal-date-badge {
  background: rgba(249, 115, 22, 0.15);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'DM Mono', monospace;
}
.modal-body {
  overflow-y: auto;
  padding: 20px 24px;
  flex: 1;
}
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  justify-content: space-between;
  align-items: center;
}
.modal-section {
  margin-bottom: 22px;
}
.modal-section:last-child {
  margin-bottom: 0;
}
.modal-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.modal-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.modal-section-hint {
  font-size: 10px;
  color: var(--text3);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

/* Form */
.form-row {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}
.form-row.two { grid-template-columns: 1fr 1fr; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.form-group {
  display: flex;
  flex-direction: column;
}
.form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
  margin-bottom: 6px;
}
.form-hint {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}
.form-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 4px;
}
.required-star {
  color: var(--accent);
  margin-left: 2px;
}

/* Calc box */
.calc-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.calc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 13px;
}
.calc-row:not(:last-child) {
  border-bottom: 1px solid var(--border);
}
.calc-label { color: var(--text2); }
.calc-value {
  font-family: 'DM Mono', monospace;
  font-weight: 500;
}
.calc-value.highlight { color: var(--accent); font-weight: 600; }
.calc-value.green { color: var(--green); }
.calc-value.blue { color: var(--blue); }
.calc-value.yellow { color: var(--yellow); }
.calc-value.purple { color: var(--purple); }
.calc-value.muted { color: var(--text3); }

/* Toggles */
.toggle-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.toggle-btn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text2);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.toggle-btn:hover {
  border-color: var(--text2);
  color: var(--text);
}
.toggle-btn.active {
  background: rgba(249, 115, 22, 0.2);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.toggle-btn.active-green {
  background: rgba(34, 197, 94, 0.2);
  border-color: var(--green);
  color: var(--green);
  font-weight: 600;
}

/* Chantier row */
.chantier-row {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 8px;
  position: relative;
}
.chantier-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 4px;
  color: var(--red);
  cursor: pointer;
  padding: 3px 10px;
  font-size: 11px;
}
.chantier-add {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px dashed var(--border2);
  border-radius: 8px;
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.chantier-add:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(249, 115, 22, 0.04);
}

.distance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text2);
  font-family: 'DM Mono', monospace;
}
.distance-badge.ok { border-color: rgba(34, 197, 94, 0.3); color: var(--green); }
.distance-badge.far { border-color: rgba(239, 68, 68, 0.3); color: var(--red); }

/* ── Tables ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 320px);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
  position: sticky;
  top: 0;
}
.data-table th:hover { color: var(--accent); }
.data-table th.sorted-asc::after { content: ' ▲'; color: var(--accent); }
.data-table th.sorted-desc::after { content: ' ▼'; color: var(--accent); }
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
.data-table td.td-wrap {
  white-space: normal;
  word-break: break-word;
  max-width: 200px;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.empty-state p { margin-bottom: 8px; }

/* Filters */
.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filters .form-group {
  flex: 1;
  min-width: 140px;
}

/* Column selector */
.col-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.col-chip {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text3);
  transition: all var(--transition);
}
.col-chip.active {
  background: rgba(249, 115, 22, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── User / Card grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all var(--transition);
}
.list-card:hover {
  border-color: var(--border2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.list-card-info {
  flex: 1;
  min-width: 0;
}
.list-card-name {
  font-weight: 600;
  font-size: 15px;
}
.list-card-meta {
  font-size: 12px;
  color: var(--text2);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.role-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-admin { background: rgba(249, 115, 22, 0.15); color: var(--accent); }
.role-compta { background: rgba(59, 130, 246, 0.15); color: var(--blue); }
.role-manager { background: rgba(139, 92, 246, 0.15); color: var(--purple); }
.role-technicien { background: rgba(34, 197, 94, 0.15); color: var(--green); }
.role-alternant { background: rgba(234, 179, 8, 0.15); color: var(--yellow); }
.role-inactive { background: var(--surface2); color: var(--text3); }

/* ── Theme toggle ── */
.theme-toggle {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 24px;
  margin-bottom: 8px;
}
.theme-opt {
  flex: 1;
  padding: 6px 0;
  border: none;
  background: transparent;
  color: var(--text3);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all var(--transition);
}
.theme-opt:hover {
  color: var(--text);
}
.theme-opt.active {
  background: var(--accent);
  color: #000;
}
.theme-opt svg {
  width: 14px;
  height: 14px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 200;
  max-width: 90%;
  animation: toastIn 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.toast.ok { border-color: rgba(34, 197, 94, 0.5); color: var(--green); }
.toast.err { border-color: rgba(239, 68, 68, 0.5); color: var(--red); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Card helper */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.card h3 {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.max-640 { max-width: 640px; }

/* ── Column resize handle ── */
.th-resize-handle {
  position: absolute;
  right: -1px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
  opacity: 0;
  transition: opacity 150ms;
}
.data-table th { position: relative; }
.data-table th:hover .th-resize-handle,
.th-resize-handle.dragging { opacity: 1; background: var(--accent); }

/* ── PWA install button ── */
.pwa-install-btn {
  background: rgba(249, 115, 22, 0.08) !important;
  border: 1px solid rgba(249, 115, 22, 0.3) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--accent) !important;
  margin-bottom: 8px;
  font-size: 12px !important;
}
.pwa-install-btn:hover { background: rgba(249, 115, 22, 0.16) !important; }

/* ── iOS PWA steps ── */
.pwa-ios-steps { list-style: none; padding: 0; }
.pwa-ios-steps li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
}
.pwa-ios-steps li:last-child { border-bottom: none; }
.pwa-ios-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 250ms ease;
    z-index: 45;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.3);
  }
  .sidebar.open { transform: none; }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    top: 56px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 44;
    display: none;
  }
  .sidebar-overlay.active { display: block; }
  .mobile-bar { display: flex !important; }
  .main-content { padding-top: 56px; }
  .main-body { padding: 16px; }
  .main-header { padding: 14px 16px; }
  .main-header h1 { font-size: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .day-grid { gap: 4px; grid-auto-rows: 68px; }
  .day-cell { min-height: 58px; padding: 6px 4px 4px; }
  .day-num { font-size: 12px; }
  .modal { max-width: 100%; border-radius: 12px; max-height: 95vh; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  .filters { flex-direction: column; }
  .filters .form-group { min-width: 0; }
  .form-row.two,
  .form-row.three { grid-template-columns: 1fr; }
  .day-grid-header span { font-size: 8px; }
  /* Table mobile */
  .table-wrap { max-height: 58vh; }
  .data-table th { padding: 8px 8px; font-size: 10px; }
  .data-table td { padding: 6px 8px; font-size: 12px; }
  .data-table td.td-wrap { max-width: 110px; }
  .data-table th:first-child,
  .data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface2);
    box-shadow: 2px 0 6px rgba(0,0,0,0.18);
  }
  .data-table th:first-child { z-index: 2; }
  .col-selector { padding: 8px; gap: 4px; }
  .col-chip { padding: 3px 8px; font-size: 10px; }
  .th-resize-handle { display: none; }
}
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .day-grid { grid-auto-rows: 56px; }
  .day-cell { min-height: 50px; padding: 4px 3px; }
  .day-tags { display: none; }
  .day-chantier { display: none; }
  .modal-date-badge { font-size: 10px; padding: 3px 8px; }
}
