/* =========================================================================
   Colibri — feuille de style
   ========================================================================= */

:root {
  --violet: #6D4AFF;
  --violet-2: #9B7BFF;
  --teal: #0E9F8A;
  --teal-2: #2DD4BF;
  --coral: #FF6B4A;
  --coral-2: #FF9A7A;

  --bg: #F5F6FB;
  --surface: #FFFFFF;
  --surface-2: #EEF0F7;
  --surface-3: #E6E8F2;
  --text: #16142B;
  --muted: #6B6F85;
  --border: rgba(22, 20, 43, .08);
  --ring: rgba(109, 74, 255, .28);

  --shadow-sm: 0 1px 2px rgba(22, 20, 43, .06), 0 1px 1px rgba(22, 20, 43, .04);
  --shadow-md: 0 10px 24px -8px rgba(22, 20, 43, .16), 0 2px 6px rgba(22, 20, 43, .06);
  --shadow-lg: 0 30px 80px -20px rgba(22, 20, 43, .35);
  --glow: 0 8px 24px -6px rgba(109, 74, 255, .55);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;

  --grad: linear-gradient(135deg, var(--violet) 0%, #8B5CF6 55%, var(--violet-2) 100%);
  --ease: cubic-bezier(.2, .8, .2, 1);

  color-scheme: light;
}

/* Thème sombre : appliqué par public/theme.js (attribut data-theme sur <html>, choix Automatique/Clair/Sombre). */
:root[data-theme="dark"] {
  --bg: #0C0B17;
  --surface: #161427;
  --surface-2: #1C1A31;
  --surface-3: #25223D;
  --text: #EDECFB;
  --muted: #9C9AB9;
  --border: rgba(255, 255, 255, .08);
  --ring: rgba(155, 123, 255, .4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 12px 28px -10px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .35);
  --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

/* --- Base ----------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(900px 500px at -10% -10%, rgba(109, 74, 255, .10), transparent 60%),
    radial-gradient(800px 500px at 110% 110%, rgba(14, 159, 138, .10), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { letter-spacing: -.02em; line-height: 1.2; }

[hidden] { display: none !important; }

::selection { background: rgba(109, 74, 255, .25); }

/* --- Barre du haut ---------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  padding: 12px 28px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; }
.brand img { height: 30px; display: block; }
/* Logo : version claire par défaut, version fond sombre en thème sombre. */
img.theme-logo-dark { display: none; }
:root[data-theme="dark"] img.theme-logo-dark { display: block; }
:root[data-theme="dark"] img.theme-logo-light { display: none; }

.nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 999px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  transition: color .2s, background .2s, box-shadow .2s;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.nav svg { width: 16px; height: 16px; }

.who { display: flex; align-items: center; gap: 12px; margin-left: auto; font-size: 14px; }
.who form { margin: 0; }
.who-name { display: grid; line-height: 1.2; }
.who-name strong { font-weight: 600; }
.who-name small { color: var(--muted); font-size: 12px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--coral); transform: none; box-shadow: none; }
.icon-btn svg { width: 18px; height: 18px; }

/* --- Avatars & badges ------------------------------------------------------ */

.avatar {
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  background: var(--grad);
}
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-planif { background: linear-gradient(135deg, var(--teal), var(--teal-2)); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.badge-manager { background: rgba(109, 74, 255, .14); color: var(--violet); }
.badge-planif { background: rgba(14, 159, 138, .14); color: var(--teal); }
:root[data-theme="dark"] .badge-manager { color: var(--violet-2); }
:root[data-theme="dark"] .badge-planif { color: var(--teal-2); }

/* --- Mise en page --------------------------------------------------------- */

.page { max-width: 1040px; margin: 0 auto; padding: 36px 28px 64px; }
.page:has(.board) { max-width: 1360px; }

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.page-head h1 { margin: 0; font-size: 30px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 18px; font-size: 17px; font-weight: 700; }

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

/* --- Formulaires ---------------------------------------------------------- */

label { display: grid; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); }

input, textarea, select { font: inherit; color: var(--text); }

input:not([type="checkbox"]), textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea { resize: vertical; min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:not([type="checkbox"]):hover, textarea:hover { border-color: var(--border); }
input:not([type="checkbox"]):focus, textarea:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--violet);
  box-shadow: 0 0 0 4px var(--ring);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 11px 20px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--grad);
  color: #fff;
  cursor: pointer;
  box-shadow: var(--glow);
  transition: transform .2s var(--ease), box-shadow .2s, filter .2s;
}
button:hover { transform: translateY(-1px); filter: brightness(1.06); }
button:active { transform: translateY(0); }
button:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
button.secondary { background: var(--surface-2); color: var(--text); box-shadow: none; }
button.secondary:hover { background: var(--surface-3); filter: none; }

.inline-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.inline-form label { flex: 1 1 220px; }
.inline-form button { min-height: 47px; }

.alert {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
}
.alert::before { font-weight: 800; }
.alert-error { background: rgba(255, 107, 74, .12); color: #D9472A; }
.alert-error::before { content: '!'; }
.alert-success { background: rgba(14, 159, 138, .12); color: var(--teal); }
.alert-success::before { content: '✓'; }
:root[data-theme="dark"] .alert-error { color: var(--coral-2); }
:root[data-theme="dark"] .alert-success { color: var(--teal-2); }

/* --- Connexion ------------------------------------------------------------ */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px;
  color: #fff;
  background:
    radial-gradient(600px 400px at 15% 20%, rgba(155, 123, 255, .9), transparent 60%),
    radial-gradient(500px 400px at 85% 75%, rgba(45, 212, 191, .7), transparent 60%),
    radial-gradient(400px 300px at 70% 15%, rgba(255, 107, 74, .55), transparent 60%),
    #16142B;
}
.auth-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .12) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, transparent, #000 40%, transparent);
  pointer-events: none;
}
.auth-hero img { height: 40px; position: relative; z-index: 1; align-self: flex-start; }
.auth-hero-text { position: relative; z-index: 1; max-width: 460px; }
.auth-hero h2 { margin: 0 0 12px; font-size: 44px; font-weight: 800; letter-spacing: -.035em; }
.auth-hero p { margin: 0; font-size: 17px; opacity: .85; }

.auth-panel { display: grid; place-items: center; padding: 32px 24px; }
.auth-form { width: 100%; max-width: 380px; display: grid; gap: 18px; }
.auth-form h1 { margin: 0; font-size: 28px; font-weight: 800; }
.auth-form > p { margin: -10px 0 4px; color: var(--muted); }
.auth-form button { width: 100%; padding: 13px 20px; font-size: 15px; margin-top: 4px; }
.auth-logo-mobile { display: none; height: 34px; }

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-logo-mobile { display: block; }
}

/* --- Kanban --------------------------------------------------------------- */

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
@media (max-width: 1200px) {
  .board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
}

.column {
  --accent: var(--muted);
  --accent-2: var(--muted);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  min-height: 220px;
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.column-todo { --accent: var(--coral); --accent-2: var(--coral-2); }
.column-doing { --accent: var(--violet); --accent-2: var(--violet-2); }
.column-waiting { --accent: #0EA5E9; --accent-2: #38BDF8; }
.column-done { --accent: var(--teal); --accent-2: var(--teal-2); }
.column.drop-target {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-2));
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}

.column-head { display: flex; align-items: center; gap: 10px; min-height: 32px; padding: 0 4px; margin-bottom: 14px; }
.column-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.column-head .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent);
}
.count {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border-radius: 999px;
  padding: 1px 9px;
  box-shadow: var(--shadow-sm);
}
.add-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  font-size: 0;
}
.add-btn svg { width: 18px; height: 18px; }

.column-empty {
  display: none;
  margin: 0;
  padding: 28px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
}
.column.is-empty .column-empty { display: block; }

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.task {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* le contenu ne peut pas élargir la carte */
  gap: 10px;
  padding: 16px 16px 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), opacity .2s;
  animation: card-in .35s var(--ease);
}
.task::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}
.task:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.task:active { cursor: grabbing; }
.task.dragging { opacity: .45; transform: rotate(1.5deg) scale(.98); }

@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.task-top { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 6px 10px; }
/* Le titre garde au moins 140px ; sinon le badge WO passe à la ligne. */
.task-top .task-title { flex: 1 1 140px; min-width: 0; }
.task-title { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.wo {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--violet);
  background: rgba(109, 74, 255, .12);
  border-radius: 999px;
  padding: 3px 9px;
}
:root[data-theme="dark"] .wo { color: var(--violet-2); }

/* Tag du work order (S2, TD, PH, S4, PD, CZ, CC, G1) */
.wo-badges { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; }
.wo-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
}
.wo-field { display: grid; gap: 14px; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.tag-picker legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tag-choice { position: relative; display: inline-flex; cursor: pointer; }
.tag-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tag-choice .wo-tag { min-width: 52px; padding: 8px 14px; font-size: 13px; text-align: center; transition: border-color .15s, background .15s, color .15s; }
.tag-choice:hover .wo-tag { border-color: var(--violet); }
.tag-choice input:checked + .wo-tag { color: #fff; background: var(--grad); border-color: transparent; }
.tag-choice input:focus-visible + .wo-tag { box-shadow: 0 0 0 4px var(--ring); }

.task { cursor: pointer; }
.info-dialog { width: min(560px, calc(100vw - 32px)); overflow-y: auto; }
.info-head-text { flex: 1; min-width: 0; }
.info-title { overflow-wrap: anywhere; }
.info-edit-btn { padding: 8px 14px; font-size: 13px; }
.info-view, .info-edit { display: grid; gap: 18px; }
.info-view[hidden], .info-edit[hidden] { display: none; }
.info-assign { display: flex; gap: 8px; margin-top: 6px; }
.info-assign[hidden] { display: none; }
.info-assign select { width: auto; flex: 1; padding: 8px 10px; }
.info-assign button { padding: 8px 14px; font-size: 13px; }
.info-section { display: grid; gap: 10px; }
.info-section h3 { margin: 0; font-size: 14px; font-weight: 800; }
.info-comments, .info-history { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.info-comments li, .info-history li { display: grid; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.info-history li { padding: 6px 12px; background: none; border-left: 2px solid var(--border); border-radius: 0; }
.info-item-head { font-size: 12px; font-weight: 600; color: var(--muted); }
.info-item-body { font-size: 14px; white-space: pre-line; overflow-wrap: anywhere; }
.info-empty { font-size: 13px; color: var(--muted); background: none !important; padding: 0 !important; border: 0 !important; }
.comment-form { display: grid; gap: 8px; }
.comment-form button { justify-self: end; padding: 8px 16px; font-size: 13px; }
.info-error[hidden] { display: none; }

.page-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-actions .btn-ghost { display: inline-flex; align-items: center; gap: 6px; }
.filter-search { flex: 1 1 220px; }
.filter-search input { width: 100%; padding: 9px 12px; }

.activity-list { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.activity-item { display: flex; gap: 14px; align-items: baseline; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.activity-time { flex: none; min-width: 44px; font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.activity-text { font-size: 14px; overflow-wrap: anywhere; }
.activity-task { color: var(--muted); }
.activity-more { margin-top: 16px; text-align: center; }
.info-list { display: grid; gap: 12px; margin: 0; }
.info-list > div { display: grid; gap: 2px; }
.info-list > div[hidden] { display: none; }
.info-list dt { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.info-list dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.info-list dd.info-text { white-space: pre-line; }

.field-hint { display: block; margin-top: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }
.task-replan { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--muted); }
.task-replan .replan-label { font-weight: 600; }
.task-replan .replan-input { width: auto; padding: 4px 8px; font-size: 13px; }
.task-replan .replan-hint { display: none; font-weight: 600; color: #B45309; }
.task-replan.is-missing .replan-hint { display: inline; }
.replan-static { font-size: 12px; font-weight: 600; color: var(--muted); }
:root[data-theme="dark"] .task-replan .replan-hint { color: #FBBF24; }

.task-desc { margin: 0; font-size: 14px; color: var(--text); opacity: .85; white-space: pre-line; overflow-wrap: anywhere; }
.task-attente {
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 8px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.task-attente strong { color: var(--text); font-weight: 600; }
.task-waiting {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  background: color-mix(in srgb, #0EA5E9 12%, var(--surface-2));
  border-left: 3px solid #0EA5E9;
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.task-waiting strong { font-weight: 700; color: #0284C7; }
.waiting-since { font-weight: 500; color: var(--muted); }
.waiting-head { display: block; }
.waiting-reason { white-space: pre-line; }
:root[data-theme="dark"] .task-waiting strong { color: #38BDF8; }
.waiting-dialog { width: min(480px, calc(100vw - 32px)); }
.waiting-task-title { font-weight: 600; color: var(--text) !important; overflow-wrap: anywhere; }
.dialog-note { margin: -4px 0 0; font-size: 14px; }
.dialog-icon-waiting { background: linear-gradient(135deg, #0EA5E9, #38BDF8) !important; }

.task-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 10px; margin-top: 2px; }
.assignee { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 0; font-size: 13px; font-weight: 600; }
.assignee-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-foot .spacer { flex: 1; }

.task-status {
  appearance: none;
  -webkit-appearance: none;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 28px 5px 11px;
  color: var(--muted);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%239C9AB9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center,
    var(--surface-2);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.task-status:hover { border-color: var(--border); color: var(--text); }
.task-status:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

/* --- Fenêtre d'ajout ------------------------------------------------------ */

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(540px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: pop-in .28s var(--ease); }
dialog::backdrop {
  background: rgba(12, 11, 23, .5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: none; }
}

.task-form { display: grid; gap: 18px; padding: 28px; }
.dialog-head { display: flex; align-items: center; gap: 12px; }
.dialog-head .dialog-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  box-shadow: var(--glow);
}
.dialog-head .dialog-icon svg { width: 20px; height: 20px; }
.dialog-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.dialog-head p { margin: 0; font-size: 13px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-text { display: grid; gap: 1px; margin-right: auto; }
.toggle-text small { font-weight: 500; color: var(--muted); font-size: 12px; }
.switch {
  position: relative;
  flex-shrink: 0;
  width: 42px;
  height: 24px;
  background: var(--surface-3);
  border-radius: 999px;
  transition: background .25s var(--ease);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .25s var(--ease);
}
.toggle input:checked + .toggle-text + .switch { background: var(--grad); }
.toggle input:checked + .toggle-text + .switch::after { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-text + .switch { box-shadow: 0 0 0 4px var(--ring); }

#wo-field:not([hidden]), #prio-field:not([hidden]) { animation: card-in .25s var(--ease); }

.prio-field { display: grid; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.prio-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.prio-picker legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.prio-choice { position: relative; display: inline-flex; cursor: pointer; }
.prio-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.prio-choice .prio { padding: 7px 14px 7px 12px; font-size: 12px; opacity: .55; outline: 2px solid transparent; outline-offset: 2px; transition: opacity .15s, outline-color .15s; }
.prio-choice:hover .prio { opacity: .85; }
.prio-choice input:checked + .prio { opacity: 1; outline-color: var(--lvl); }
.prio-choice input:focus-visible + .prio { box-shadow: 0 0 0 4px var(--ring); }
.hold-field { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.hold-input { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; color: var(--muted); }
.hold-input input { width: 80px; text-align: center; }
.prio-hint { margin: 0; font-size: 12px; color: var(--muted); }
.prio-hint:empty { display: none; }

/* --- Tableau des utilisateurs -------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.user-cell { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.table-scroll { overflow-x: auto; }
.user-actions { display: flex; flex-wrap: wrap; align-items: start; gap: 6px 14px; }
.user-password summary { cursor: pointer; }
.user-password form { margin-top: 8px; }

.empty-state { padding: 28px; text-align: center; color: var(--muted); }

/* --- Priorité ------------------------------------------------------------- */

:root {
  --lvl-faible: #22C55E;
  --lvl-normale: #F59E0B;
  --lvl-urgente: #EF4444;
}
:root[data-theme="dark"] {
  --lvl-faible: #4ADE80;
  --lvl-normale: #FBBF24;
  --lvl-urgente: #F87171;
}

.level-faible, .prio-faible { --lvl: var(--lvl-faible); }
.level-normale, .prio-normale { --lvl: var(--lvl-normale); }
.level-urgente, .prio-urgente { --lvl: var(--lvl-urgente); }

.prio {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--lvl);
  background: color-mix(in srgb, var(--lvl) 13%, transparent);
}
.prio::before {
  content: '';
  width: 12px;
  height: 12px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.prio-faible {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3C/svg%3E");
}
.prio-normale {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4 21 19H3z'/%3E%3C/svg%3E");
}
.prio-urgente {
  --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2 4.1 12.6a1 1 0 0 0 .8 1.6H11l-1 7.8 8.9-10.6a1 1 0 0 0-.8-1.6H13l1-7.8Z'/%3E%3C/svg%3E");
  color: #fff;
  background: linear-gradient(135deg, var(--lvl-urgente), #F43F5E);
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--lvl-urgente) 70%, transparent);
}
/* Priorité choisie à la création : fin contour pour la distinguer de l'automatique. */
.prio-manual { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lvl) 45%, transparent); }
.prio-urgente.prio-manual { box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--lvl-urgente) 70%, transparent); }

/* Haut de la carte : niveau à gauche, ancienneté J+N à droite. Normale et Urgente prennent la forme d'un
   panneau de signalisation (triangle d'avertissement) ; Faible garde sa pastille. */
.task-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.task-age {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .03em;
  color: var(--muted);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}
.task-age { margin-left: auto; } /* J+N poussé à droite */
.task-hold { font-weight: 600; opacity: .8; }
/* L'ancienneté n'a de sens que dans « Non assigné », où la priorité monte encore. */
.column:not(.column-todo) .task-age { display: none; }
.level-sign {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--lvl);
}
.task.level-normale .level-sign, .task.level-urgente .level-sign { display: inline-flex; }
.task.level-normale .task-meta .prio, .task.level-urgente .task-meta .prio { display: none; }
.sign-icon { width: 28px; height: 28px; flex: none; overflow: visible; }
.sign-body { fill: #fff; stroke: var(--lvl); stroke-width: 2.6; stroke-linejoin: round; }
.sign-mark { stroke: #16142B; stroke-width: 2.4; stroke-linecap: round; }
.sign-dot { fill: #16142B; }
.task.level-urgente .sign-icon { filter: drop-shadow(0 2px 5px color-mix(in srgb, var(--lvl-urgente) 55%, transparent)); }
/* Priorité choisie à la création : le panneau est un peu plus épais. */
.level-sign.is-manual .sign-body { stroke-width: 3.2; }

.settings-form { display: grid; gap: 18px; max-width: 520px; margin-top: 16px; }
.setting-row { display: flex; align-items: center; gap: 16px; }
.setting-row .prio { flex: none; min-width: 104px; justify-content: center; }
.setting-row label { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.setting-row input[type="number"] { width: 90px; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-note { max-width: 640px; margin-top: 20px; font-size: 13px; }

/* Choix du thème (page Paramètres) : même style que le sélecteur de vue. */
.theme-choice { display: inline-flex; gap: 4px; margin: 0; padding: 4px; border: 0; background: var(--surface-2); border-radius: 999px; }
.theme-option { position: relative; display: inline-flex; cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; }
.theme-option span { padding: 7px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background .2s, color .2s, box-shadow .2s; }
.theme-option:hover span { color: var(--text); }
.theme-option input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.theme-option input:focus-visible + span { box-shadow: 0 0 0 3px var(--ring); }

/* Le liseré de la carte prend la couleur de la priorité. */
.task[class*="level-"]::before { background: var(--lvl); }
.task.level-urgente {
  border-color: color-mix(in srgb, var(--lvl-urgente) 35%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--lvl-urgente) 7%, transparent), transparent 60%),
    var(--surface);
}
.task.level-normale {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--lvl-normale) 5%, transparent), transparent 50%),
    var(--surface);
}

/* --- Archive -------------------------------------------------------------- */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.archive-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.archive-filter input { width: auto; padding: 9px 12px; }
.archive-filter button { padding: 10px 16px; }
.btn-ghost { font-size: 14px; font-weight: 600; color: var(--muted); padding: 8px 6px; }

.archive { display: grid; gap: 28px; }
.archive-day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-left: 4px; }
.archive-day-head h2 { margin: 0; font-size: 17px; font-weight: 800; }

.archive-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.archive-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border-radius: var(--radius);
  transition: background .15s;
}
.archive-item + .archive-item { border-top: 1px solid var(--border); border-radius: 0; }
.archive-item:hover { background: var(--surface-2); }
.archive-check {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
}
.archive-check svg { width: 14px; height: 14px; }
.archive-body { display: grid; gap: 8px; min-width: 0; }
.archive-meta { display: grid; justify-items: end; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.archive-dates { display: grid; gap: 3px; margin: 0; text-align: right; }
.archive-dates div { display: flex; justify-content: flex-end; gap: 8px; }
.archive-dates dt { font-weight: 500; color: var(--muted); }
.archive-dates dd { margin: 0; color: var(--text); font-weight: 600; white-space: nowrap; }
.delay {
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--lvl);
  background: color-mix(in srgb, var(--lvl) 12%, transparent);
}
.delay-0 { --lvl: var(--teal); }
.delay-1 { --lvl: var(--lvl-normale); }
.delay-2 { --lvl: var(--lvl-urgente); }
@media (max-width: 640px) {
  .archive-item { grid-template-columns: auto 1fr; }
  .archive-meta { grid-column: 2; justify-items: start; gap: 8px; }
  .archive-dates, .archive-dates div { text-align: left; justify-content: flex-start; }
}

/* --- Mode démo (temporaire, voir src/demo.js) ------------------------------ */

.demo-btn {
  padding: 8px 14px;
  font-size: 13px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
}
.demo-btn:hover { background: var(--surface-3); filter: none; }
.demo-btn svg { width: 16px; height: 16px; }

.demo-banner {
  position: sticky;
  top: 61px;
  z-index: 9;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  padding: 9px 20px;
  font-size: 14px;
  color: #5A3A00;
  background: linear-gradient(90deg, #FFE7A8, #FFD27A);
  border-bottom: 1px solid rgba(90, 58, 0, .15);
}
.demo-banner form { margin: 0; }
.demo-dot { width: 8px; height: 8px; border-radius: 50%; background: #E07B00; box-shadow: 0 0 0 4px rgba(224, 123, 0, .2); }
.demo-banner button { padding: 6px 14px; font-size: 13px; box-shadow: none; }
.demo-banner .demo-link { background: transparent; color: #5A3A00; text-decoration: underline; padding: 6px 4px; }
.demo-banner .demo-exit { background: #5A3A00; color: #fff; }
@media (max-width: 640px) { .demo-banner { top: 0; position: relative; } }

/* --- Suppression ------------------------------------------------------------ */

.task-delete {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  opacity: .55;
  transition: opacity .15s, background .15s, color .15s;
}
.task-delete svg { width: 16px; height: 16px; }
.task:hover .task-delete, .task-delete:focus-visible { opacity: 1; }
.task-delete:hover { background: color-mix(in srgb, var(--lvl-urgente) 12%, transparent); color: var(--lvl-urgente); transform: none; filter: none; }
/* Une tâche terminée ne se supprime pas. */
.column-done .task-delete { display: none; }
.task.is-removing { opacity: 0; transform: scale(.96); transition: opacity .2s, transform .2s; }

button.danger { background: linear-gradient(135deg, #EF4444, #E11D48); box-shadow: 0 8px 24px -6px rgba(225, 29, 72, .5); }
.dialog-icon-danger { background: linear-gradient(135deg, #EF4444, #E11D48) !important; box-shadow: 0 8px 24px -6px rgba(225, 29, 72, .5) !important; }
.delete-dialog { width: min(460px, calc(100vw - 32px)); }
.delete-task-title { font-weight: 600; color: var(--text) !important; overflow-wrap: anywhere; }
.delete-note { margin: -4px 0 0; font-size: 14px; }
.optional { font-weight: 500; opacity: .7; }

.deleted-mark { background: linear-gradient(135deg, #9CA3AF, #6B7280); }
.deleted-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.deleted-title { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.state-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--muted);
  background: var(--surface-2);
}
.state-waiting { color: #0284C7; background: color-mix(in srgb, #0EA5E9 14%, transparent); }
:root[data-theme="dark"] .state-waiting { color: #38BDF8; }
.delete-reason {
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--muted);
  background: color-mix(in srgb, var(--lvl-urgente) 6%, var(--surface-2));
  border-radius: 8px;
  overflow-wrap: anywhere;
}
.delete-reason strong { color: var(--text); font-weight: 600; }
.empty-icon-muted { background: linear-gradient(135deg, #9CA3AF, #6B7280); box-shadow: 0 10px 28px -8px rgba(107, 114, 128, .5); }
.kpi-link { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.kpi-link:hover { color: var(--text); }

/* --- Choix du planif ------------------------------------------------------ */

.assign-dialog { width: min(440px, calc(100vw - 32px)); }
.assign-task-title { font-weight: 600; color: var(--text) !important; overflow-wrap: anywhere; }
.planif-picker {
  display: grid;
  gap: 6px;
  margin: 0 -4px;
  padding: 4px;
  border: 0;
  max-height: 320px;
  overflow-y: auto;
}
.planif-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.planif-option:hover { background: var(--surface-2); }
.planif-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.planif-option:has(input:checked) {
  border-color: var(--violet);
  background: color-mix(in srgb, var(--violet) 8%, var(--surface));
  box-shadow: 0 0 0 3px var(--ring);
}
.planif-option:has(input:focus-visible) { outline: 2px solid var(--violet); outline-offset: 2px; }

/* --- Statistiques --------------------------------------------------------- */

/* Palette catégorielle validée (validate_palette.js) sur les surfaces #FFFFFF et #161427. */
.viz-root {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --series-other: #9a9aa8;
  --chart-grid: rgba(22, 20, 43, .08);
}
:root[data-theme="dark"] .viz-root {
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #6f6d86;
  --chart-grid: rgba(255, 255, 255, .08);
}

.stats-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  margin-bottom: 20px;
}
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.segmented a {
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  transition: background .2s, color .2s, box-shadow .2s;
}
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented-sm button {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border-radius: 999px;
  box-shadow: none;
}
.segmented-sm button:hover { transform: none; filter: none; color: var(--text); }
.segmented-sm button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.stats-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stats-form input { width: auto; padding: 9px 12px; }
.stats-form .input-year { width: 110px; }
.stats-form button { padding: 10px 18px; }
.inline-label { display: flex; align-items: center; gap: 8px; font-size: 14px; }
a.icon-btn:hover { text-decoration: none; color: var(--text); }
.icon-btn.is-disabled { opacity: .35; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { display: grid; gap: 4px; margin: 0; padding: 20px 22px; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.kpi-value small { font-size: 20px; font-weight: 700; margin-left: 2px; color: var(--muted); }
.kpi-sub { font-size: 13px; color: var(--muted); }

.chart-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card { margin-bottom: 20px; }
.chart-head { display: flex; flex-wrap: wrap; align-items: start; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
.chart-head h2 { margin: 0; }
.chart-head p { margin: 4px 0 0; font-size: 13px; }
.chart-box { position: relative; height: 300px; }
.chart-empty { margin: 0; padding: 48px 16px; text-align: center; color: var(--muted); border: 1.5px dashed var(--border); border-radius: var(--radius); }

.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend strong { color: var(--text); }
.legend-wrap { margin-bottom: 14px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.swatch-line { height: 3px; width: 16px; border-radius: 2px; }

.data-table { margin-top: 14px; font-size: 14px; }
.data-table summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); width: fit-content; }
.data-table summary:hover { color: var(--text); }
.data-table table { margin-top: 10px; }
.table-scroll { overflow-x: auto; }

/* --- Mes tâches ----------------------------------------------------------- */

.board-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.board.board-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .board.board-3 { grid-template-columns: 1fr; } }

/* --- Filtres du tableau ------------------------------------------------------ */

.board-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 12px 16px;
  margin-bottom: 20px;
}
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filter-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.board-filters .segmented { flex-wrap: wrap; border-radius: 16px; }
.filter-reset {
  margin-left: auto;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--muted);
  background: none;
  box-shadow: none;
  text-decoration: underline;
}
.filter-reset:hover { color: var(--text); transform: none; filter: none; }
.filter-select {
  width: auto;
  min-width: 150px;
  padding: 8px 34px 8px 12px;
  font-size: 14px;
  font-weight: 600;
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%239C9AB9' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}
.filter-select:hover { border-color: var(--border); }
.filter-select:focus-visible { outline: none; border-color: var(--violet); box-shadow: 0 0 0 4px var(--ring); }
.filter-group .filter-label { cursor: default; }
.filter-level::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lvl);
}
.filter-level-faible { --lvl: var(--lvl-faible); }
.filter-level-normale { --lvl: var(--lvl-normale); }
.filter-level-urgente { --lvl: var(--lvl-urgente); }
@media (max-width: 900px) { .board-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--glow);
  transition: transform .2s var(--ease), filter .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); filter: brightness(1.06); }

.empty-hero { max-width: 520px; margin: 6vh auto 0; padding: 44px 32px; text-align: center; }
.empty-hero h2 { margin: 16px 0 6px; font-size: 20px; }
.empty-hero p { margin: 0 0 22px; }
.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--teal-2));
  box-shadow: 0 10px 28px -8px rgba(14, 159, 138, .6);
}
.empty-icon svg { width: 28px; height: 28px; }

/* --- Erreur --------------------------------------------------------------- */

.error-page { max-width: 460px; margin: 10vh auto 0; text-align: center; }
.error-page h1 { font-size: 64px; margin: 0; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* --- Mobile --------------------------------------------------------------- */

@media (max-width: 640px) {
  .topbar { padding: 10px 16px; gap: 10px 16px; }
  .who-name { display: none; }
  /* Sur mobile, le menu défile horizontalement dans sa propre barre au lieu d'élargir la page. */
  .nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 1 0 auto; justify-content: center; padding: 7px 14px; }
  .page { padding: 24px 16px 48px; }
  .page-head h1 { font-size: 24px; }
  .card { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --- Backlog : dépôt du reporting Excel ---------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 24px;
  text-align: center;
  cursor: pointer;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  transition: border-color .2s var(--ease), background .2s var(--ease);
}
.dropzone svg { width: 34px; height: 34px; color: var(--violet); }
.dropzone:hover, .dropzone.is-over { border-color: var(--violet); background: var(--ring); }
.backlog-error { margin: 14px 0 0; color: var(--coral); font-weight: 600; }
.backlog-drop p[hidden] { display: none; }
.backlog-missing { margin: 0 0 16px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--coral); }

/* Grande page de vérification : toute la largeur, en-tête fixe, défilement dans le tableau. */
.page:has(.backlog-layout) { max-width: none; padding-top: 20px; padding-bottom: 24px; }
.backlog-main { min-width: 0; }
.backlog-drop { max-width: 720px; }
.backlog-current { max-width: 720px; margin-top: 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.backlog-current-text { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }

/* Listes des pages Archive et Suppressions : ces règles complètent celles de la section Archive. */
.archive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.archive-item { position: relative; display: flex; align-items: flex-start; gap: 4px; border-radius: var(--radius-sm); }
.archive-item:hover { background: var(--surface-2); }

.backlog-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.backlog-bar h1 { margin: 2px 0 2px; font-size: 22px; font-weight: 800; overflow-wrap: anywhere; }
.backlog-bar p { margin: 0; }
.backlog-bar .btn-ghost { padding-left: 0; }
.backlog-scroll {
  overflow: auto;
  max-height: calc(100vh - 260px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.backlog-grid { width: max-content; min-width: 100%; font-size: 13px; }
.backlog-grid th, .backlog-grid td { padding: 7px 12px; white-space: nowrap; border-right: 1px solid var(--border); }
.backlog-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #6D84C6;
  color: #fff;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: bottom;
  white-space: normal;
  min-width: 110px;
}
.backlog-grid th.is-missing { background: #8D9CCB; }
.backlog-grid td.is-missing { background: var(--surface-2); }
.backlog-grid td.is-highlight { background: #FF8C2E; color: #16142B; font-weight: 700; }
.backlog-grid .row-no { min-width: 0; width: 1%; text-align: right; color: var(--muted); background: var(--surface-2); font-variant-numeric: tabular-nums; }
.backlog-grid thead th.row-no { color: #fff; background: #5A70B3; }

/* Statut et commentaires : colonnes de suivi, à écrire dans le tableau */
.st-canceled { background: #D13438 !important; color: #fff !important; }
.st-parts { background: #E8CFCF !important; color: #16142B !important; }
.st-scheduled { background: #4CAF73 !important; color: #16142B !important; }
.st-cu { background: #9BE564 !important; color: #16142B !important; }
.st-to-plan { background: #F5F03A !important; color: #16142B !important; }
.st-closed { background: #5BB5E8 !important; color: #16142B !important; }
.st-td { background: #E3B79F !important; color: #16142B !important; }
.st-other { background: #F2F2F2 !important; color: #16142B !important; }
.status-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 12px; padding: 0; font-size: 12px; }
.status-legend li { display: flex; align-items: center; gap: 6px; }
.status-chip { padding: 2px 9px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.backlog-grid thead th.track-head { background: #3F5AA8; }
.backlog-grid td.track-cell { padding: 3px 6px; background: var(--surface); }
.backlog-grid .track-cell input {
  font: inherit; font-size: 13px; padding: 5px 8px; margin: 0; width: 100%; min-width: 0;
  border: 1px solid var(--border); border-radius: 6px; box-shadow: none; background: var(--surface); color: var(--text);
}
.backlog-grid .status-input { min-width: 130px; font-weight: 700; }
.backlog-grid .track-comment { min-width: 300px; }
.backlog-grid td.track-stamp { min-width: 140px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.backlog-grid thead th.track-head-stamp { background: #3F5AA8; }
.backlog-grid .track-cell input:focus { outline: 2px solid var(--violet); outline-offset: 0; }
.save-toast {
  position: fixed; right: 20px; bottom: 20px; padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity .2s, transform .2s;
}
.save-toast.is-visible { opacity: 1; transform: none; }
.save-toast.is-error { background: var(--coral); color: #fff; }

/* Validation d'une archive */
.backlog-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.backlog-actions form { margin: 0; }
.btn-validate { background: var(--teal); box-shadow: 0 8px 24px -6px rgba(14, 159, 138, .55); border: 0; cursor: pointer; }
.validated-box { display: flex; align-items: center; gap: 8px; }
.validated-badge { padding: 9px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 700; color: #fff; background: var(--teal); }

/* Premier / Standard et rendez-vous tardifs */
.kind-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 10px; }
.kind-filter { display: inline-flex; gap: 4px; padding: 3px; border-radius: 12px; background: var(--surface-2); }
.kind-filter button { padding: 6px 14px; border: 0; border-radius: 9px; font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); background: transparent; box-shadow: none; cursor: pointer; }
.kind-filter button span { margin-left: 4px; font-weight: 600; opacity: .8; font-variant-numeric: tabular-nums; }
.kind-filter button.is-active { color: var(--text); background: var(--surface); box-shadow: var(--shadow-sm); }
.kind-filter button:hover { transform: none; filter: none; }
.kind-note { font-size: 12px; }
.late-sample, .backlog-grid td.is-late { color: #D13438; font-weight: 700; }
.kind-badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.kind-premier { color: #fff; background: #6D4AFF; }
.kind-standard { color: var(--text); background: var(--surface-2); border: 1px solid var(--border); }
.backlog-grid tbody tr[hidden] { display: none; }

/* Fenêtre de confirmation (pages Backlog) */
.confirm-dialog { width: min(440px, calc(100vw - 32px)); }
.confirm-head-text { min-width: 0; }
.confirm-head-text h2 { font-size: 19px; }
.confirm-head-text p { overflow-wrap: anywhere; }
.confirm-text { margin: 0; font-size: 14px; line-height: 1.55; }
.dialog-icon-success { background: linear-gradient(135deg, #0E9F8A, #22C3A8) !important; box-shadow: 0 8px 24px -6px rgba(14, 159, 138, .55) !important; }
.dialog-icon-neutral { background: var(--grad) !important; }
button.success { background: linear-gradient(135deg, #0E9F8A, #22C3A8); box-shadow: 0 8px 24px -6px rgba(14, 159, 138, .55); }

/* --- Assistant de création de tâches ---------------------------------------- */

.assistant { position: fixed; right: 20px; bottom: 20px; z-index: 40; display: flex; flex-direction: column-reverse; align-items: flex-end; gap: 12px; } /* le bouton reste en bas, le panneau s'ouvre au-dessus */
.assistant-fab {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  color: #fff;
  background: var(--grad);
  box-shadow: var(--glow), var(--shadow-md);
}
.assistant-fab svg { width: 24px; height: 24px; }
.assistant-panel {
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 110px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in .25s var(--ease);
}
.assistant-panel[hidden] { display: none; }
.assistant-head { display: flex; align-items: center; gap: 4px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--border); }
.assistant-head > div { flex: 1; min-width: 0; }
.assistant-head h2 { margin: 0; font-size: 16px; font-weight: 800; }
.assistant-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.assistant-log { display: grid; align-content: start; gap: 10px; padding: 14px 16px; overflow-y: auto; min-height: 120px; }
.assistant-msg { max-width: 88%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-line; }
.assistant-msg-user { justify-self: end; color: #fff; background: var(--grad); border-bottom-right-radius: 4px; }
.assistant-msg-bot { justify-self: start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.assistant-msg-error { justify-self: start; color: #B91C1C; background: color-mix(in srgb, #EF4444 12%, transparent); border-bottom-left-radius: 4px; }
.assistant-msg.is-waiting { color: var(--muted); font-style: italic; }
.assistant-reload { margin-top: 8px; padding: 6px 12px; font-size: 13px; }
.assistant-form { display: grid; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); }
.assistant-form textarea { resize: none; font-size: 14px; }
.assistant-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.assistant-actions button { padding: 8px 16px; font-size: 14px; }
.assistant-mic { display: grid; place-items: center; width: 38px; height: 38px; padding: 0 !important; border-radius: 50%; color: var(--text); background: var(--surface-2); box-shadow: none; }
.assistant-mic[hidden] { display: none; }
.assistant-mic svg { width: 18px; height: 18px; }
.assistant-mic.is-listening { color: #fff; background: #EF4444; animation: assistant-pulse 1.2s ease-in-out infinite; }
@keyframes assistant-pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, #EF4444 22%, transparent); } }
@media (prefers-reduced-motion: reduce) { .assistant-mic.is-listening { animation: none; } }
.assistant-hint { margin: 0; padding: 0 16px 12px; font-size: 12px; color: var(--muted); }
.assistant-hint:empty { display: none; }

.assistant-draft { display: grid; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--violet); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.assistant-draft-title { margin: 0; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--violet); }
.assistant-field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.assistant-field[hidden] { display: none; }
.assistant-field input, .assistant-field select, .assistant-field textarea { width: 100%; padding: 7px 10px; font-size: 14px; font-weight: 400; color: var(--text); }
.assistant-field textarea { resize: vertical; }
.assistant-problem { margin: 0; font-size: 13px; color: #B91C1C; }
.assistant-problem[hidden] { display: none; }
.assistant-draft-actions { display: flex; justify-content: flex-end; gap: 8px; }
.assistant-draft-actions button { padding: 8px 16px; font-size: 14px; }
/* Work order déjà existant : le choix prend la place du brouillon. */
.assistant-draft.has-conflict > :not(.assistant-conflict) { display: none; }
.assistant-conflict { display: grid; gap: 10px; }
.assistant-conflict select { width: 100%; padding: 7px 10px; font-size: 14px; }
.assistant-conflict-old { margin: 0; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
.assistant-conflict-note { margin: 0; font-size: 13px; color: var(--muted); }
.assistant-conflict-actions { flex-wrap: wrap; }
.assistant-choices { display: grid; gap: 8px; }
.assistant-choice { display: grid; gap: 6px; margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; min-width: 0; }
.assistant-choice:disabled { opacity: .5; }
.assistant-choice legend { padding: 0 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.assistant-choice label { display: flex; align-items: flex-start; gap: 8px; margin: 0; font-size: 13px; font-weight: 400; color: var(--text); cursor: pointer; }
.assistant-choice input { flex: none; width: auto; margin: 3px 0 0; }
.assistant-choice span { min-width: 0; overflow-wrap: anywhere; white-space: pre-line; }
:root[data-theme="dark"] .assistant-msg-error, :root[data-theme="dark"] .assistant-problem { color: #FCA5A5; }
@media (max-width: 600px) { .assistant { right: 12px; bottom: 12px; } }
