/* rustplanner — banc d'essai du solveur.
   Palette : instance de référence (catégorielle validée daltonisme, clair et sombre). */

:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ed;
  --border: rgba(11, 11, 11, 0.10);
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --focus: #2a78d6;

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;

  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border: rgba(255, 255, 255, 0.10);
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --focus: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: rgba(255, 255, 255, 0.10);
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --accent: #3987e5;
  --focus: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--text-primary);
  font: 14px/1.45 var(--font);
}

h2 { font-size: 16px; margin: 0 0 10px; font-weight: 600; }
h3 { font-size: 14px; margin: 18px 0 8px; font-weight: 600; }
.card h3:first-child { margin-top: 0; }
p { margin: 0 0 8px; }
sup { font-size: 0.7em; }

button, input, select { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.hint { color: var(--text-secondary); font-size: 12.5px; }
.small { font-size: 12.5px; }

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

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand strong { font-size: 16px; }
.brand-sub { color: var(--text-secondary); }
.server-info { margin-left: auto; color: var(--text-secondary); font-size: 12.5px; }

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

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
  padding: 16px 20px 40px;
  align-items: start;
}
.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
.main { min-width: 0; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px 32px; }
  .sidebar { position: static; max-height: none; overflow: visible; }
}

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 0 0 16px;
}
.sidebar .card { margin: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin-bottom: 8px; }

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

.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 10px; }
.field input, .field select, .toolbar select, .toolbar input[type="search"] {
  font-size: 14px; color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--axis);
  border-radius: 6px;
  padding: 6px 8px;
  min-width: 0;
}
.field input, .field select { width: 100%; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 10px; }

details.sub { margin: 4px 0 10px; }
details.sub > summary, details.card > summary { cursor: pointer; color: var(--text-secondary); font-size: 13px; padding: 4px 0; }
details.sub[open] > summary { margin-bottom: 8px; }
details.card > summary { font-weight: 600; color: var(--text-primary); font-size: 14px; }

button {
  cursor: pointer;
  border: 1px solid var(--axis);
  background: var(--surface-1);
  border-radius: 6px;
  padding: 6px 12px;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button.small { padding: 3px 9px; font-size: 12.5px; }
button.wide { width: 100%; margin: 4px 0 8px; }

.upload-row { margin: -4px 0 6px; }
.form-error {
  color: var(--text-primary);
  border-left: 3px solid var(--critical);
  background: color-mix(in srgb, var(--critical) 10%, transparent);
  padding: 6px 8px; border-radius: 4px; font-size: 12.5px; white-space: pre-wrap;
}

/* --- Liste des runs ----------------------------------------------------- */

.runs-card { min-height: 120px; }
.run-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.run-list li {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center;
  border-radius: 6px; padding: 4px 6px;
}
.run-list li:hover { background: var(--surface-2); }
.run-list li.selected { background: color-mix(in srgb, var(--accent) 12%, var(--surface-1)); }
.run-list input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.run-main { all: unset; cursor: pointer; display: flex; flex-direction: column; min-width: 0; padding: 2px 0; }
.run-main:focus-visible { outline: 2px solid var(--focus); border-radius: 4px; }
.run-top { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.run-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-score { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12.5px; white-space: nowrap; }
.run-sub { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-acts { display: flex; gap: 2px; }
.run-acts button { padding: 1px 7px; font-size: 12px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex: none; }

.status { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.status.en_cours::before { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.status.termine::before { background: var(--good); }
.status.arrete::before { background: var(--warning); }
.status.erreur::before { background: var(--critical); }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .status.en_cours::before { animation: none; } }

/* --- Onglets ------------------------------------------------------------ */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; padding: 8px 14px; color: var(--text-secondary); white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button:hover { background: var(--surface-2); }

.tab-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tab-head h2 { margin-bottom: 2px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { color: var(--text-secondary); padding: 40px 0; text-align: center; }

.toolbar { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 0 0 12px; }
.toolbar.tight { gap: 8px; margin: 0 0 8px; }
.check { display: inline-flex; gap: 6px; align-items: center; color: var(--text-secondary); font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); }

.note {
  border-left: 3px solid var(--warning);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  padding: 8px 10px; border-radius: 4px;
}

/* --- Tuiles ------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.tile .k { font-size: 12px; color: var(--text-secondary); }
.tile .v { font-size: 20px; font-weight: 600; line-height: 1.25; margin-top: 2px; }
.tile .s { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.tile.score .v { display: flex; gap: 12px; flex-wrap: wrap; }
.tile.score .v span { display: inline-flex; flex-direction: column; }
.tile.score .v small { font-size: 11px; font-weight: 400; color: var(--text-secondary); }
.tile.wide { grid-column: span 2; }
@media (max-width: 520px) { .tile.wide { grid-column: span 1; } }

/* --- Graphiques --------------------------------------------------------- */

figure { margin: 0 0 16px; }
.chart-card figcaption { font-weight: 600; margin-bottom: 6px; }
.charts2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .charts2 { grid-template-columns: 1fr; } }
/* Le canvas est hors flux : sa largeur en pixels ne doit jamais élargir le conteneur. */
.chart { position: relative; width: 100%; }
.chart canvas { display: block; position: absolute; left: 0; top: 0; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  padding: 6px 8px; font-size: 12px; min-width: 140px; max-width: 280px;
}
.chart-tip .t { color: var(--text-secondary); margin-bottom: 3px; }
.chart-tip .r { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.chart-tip .r b { margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; font-weight: 600; }

.legend { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); align-items: center; }
.legend .item { display: inline-flex; gap: 6px; align-items: center; }
.legend.big { margin-bottom: 12px; font-size: 13px; color: var(--text-primary); }
.legend .item button { padding: 0 6px; font-size: 12px; line-height: 1.4; }

/* --- Tableaux ----------------------------------------------------------- */

.table-wrap { overflow-x: auto; max-width: 100%; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data th { color: var(--text-secondary); font-weight: 600; font-size: 12px; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover, table.clickable tbody tr.active { background: var(--surface-2); }
table.data tr.best td { font-weight: 600; }
table.data td.nowrap { white-space: nowrap; }
table.data td.params { min-width: 300px; }

.bar-cell { min-width: 120px; }
.bar { height: 8px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }

.lvl { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; white-space: nowrap; }
.lvl::before { font-size: 11px; }
.lvl.hard::before { content: "✖"; color: var(--critical); }
.lvl.medium::before { content: "▲"; color: var(--serious); }
.lvl.soft::before { content: "•"; color: var(--muted); font-size: 16px; line-height: 0.8; }

.stats { display: flex; gap: 10px 24px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; }
.stats div b { font-variant-numeric: tabular-nums; }

/* --- Grille du planning ------------------------------------------------- */

table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
table.grid th, table.grid td { border-bottom: 1px solid var(--grid); border-right: 1px solid var(--grid); padding: 4px 6px; vertical-align: top; }
table.grid thead th { position: sticky; top: 0; background: var(--surface-1); font-weight: 600; text-align: left; white-space: nowrap; z-index: 1; }
table.grid thead th.closed { color: var(--text-secondary); font-weight: 400; }
table.grid th.emp { position: sticky; left: 0; background: var(--surface-1); text-align: left; font-weight: 400; min-width: 150px; z-index: 1; }
table.grid th.emp .n { font-weight: 600; white-space: nowrap; }
table.grid th.emp .r { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; }
@media (max-width: 520px) {
  table.grid th.emp { min-width: 104px; }
  table.grid th.emp .n { white-space: normal; }
  table.grid th.emp .r { display: none; }
  table.grid td.pc { min-width: 80px; }
}
table.grid td.pc { position: relative; min-width: 92px; cursor: pointer; }
table.grid td.pc:hover { background: var(--surface-2); }
table.grid td.work { box-shadow: inset 3px 0 0 var(--shift); background: color-mix(in srgb, var(--shift) 9%, var(--surface-1)); }
table.grid td.work:hover { background: color-mix(in srgb, var(--shift) 16%, var(--surface-1)); }
table.grid td.rest { color: var(--text-secondary); }
table.grid td.rest .l1 { font-style: italic; }
table.grid td.closed { background: repeating-linear-gradient(45deg, transparent 0 6px, var(--surface-2) 6px 7px); color: var(--muted); }
table.grid td.focus { outline: 2px solid var(--focus); outline-offset: -2px; }
table.grid td.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: color-mix(in srgb, var(--accent) 35%, var(--surface-1)); } }
@media (prefers-reduced-motion: reduce) { table.grid td.flash { animation: none; } }
.l1 { font-weight: 600; white-space: nowrap; }
.l2 { font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; }
.role.backup { text-decoration: underline dotted; text-underline-offset: 2px; }
.pin { color: var(--text-secondary); font-size: 10px; }
td.hours { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.hours .d { display: block; font-size: 11.5px; color: var(--text-secondary); }

.vb {
  position: absolute; top: 3px; right: 3px;
  font-size: 10.5px; line-height: 1; padding: 2px 4px; border-radius: 4px;
  background: var(--surface-1); border: 1px solid var(--border); color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.vb.hard { border-color: var(--critical); }
.vb.hard::before { content: "✖ "; color: var(--critical); }
.vb.medium { border-color: var(--serious); }
.vb.medium::before { content: "▲ "; color: var(--serious); }
.vb.soft { border-color: transparent; background: transparent; color: var(--text-secondary); }
.vb.soft::before { content: "• "; color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--axis); padding: 4px 12px; background: transparent; }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

table.coverage td, table.coverage thead th:not(:first-child) { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.coverage tbody th { font-weight: 400; color: var(--text-primary); }
table.coverage td.miss { background: color-mix(in srgb, var(--critical) 14%, transparent); font-weight: 600; }
table.coverage td.miss::before { content: "▼ "; color: var(--critical); font-size: 10px; }
table.coverage td.surplus { color: var(--text-secondary); }
table.coverage td.none { color: var(--muted); }
table.coverage th.col-focus, table.coverage td.col-focus { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--accent) 10%, transparent); }

/* Reste visible en bas de l'écran tant que la grille défile au-dessus. */
.detail {
  margin-top: 14px; position: sticky; bottom: 12px; z-index: 3;
  max-height: 45vh; overflow: auto; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 8px; font-size: 13px; }
.detail dt { color: var(--text-secondary); }
.detail dd { margin: 0; }
.detail ul { margin: 4px 0 0; padding-left: 0; list-style: none; font-size: 13px; }
.detail li { margin-bottom: 3px; }

/* --- Dialogue et messages ---------------------------------------------- */

dialog {
  border: 1px solid var(--border); border-radius: 10px; padding: 20px;
  background: var(--surface-1); color: var(--text-primary); max-width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  background: var(--surface-1); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 6px; padding: 8px 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); font-size: 13px; white-space: pre-wrap;
}
.toast.error { border-left-color: var(--critical); }

/* --- Mode hébergé : connexion, espace du responsable, administration --- */

.auth { max-width: 380px; margin: 0 auto; padding: 12vh 16px 40px; }
.auth-brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.auth-brand strong { font-size: 20px; }
.auth .card { padding: 18px 20px; }
.auth .field input { font-size: 15px; padding: 8px 10px; }

.page { max-width: 1100px; margin: 0 auto; padding: 16px 20px 40px; }
@media (max-width: 640px) { .page { padding: 12px 16px 32px; } }

.account-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar .server-info ~ .account-nav { margin-left: 0; }
.nav-link { color: var(--accent); text-decoration: none; font-size: 13px; padding: 3px 6px; border-radius: 6px; }
.nav-link:hover { background: var(--surface-2); }

.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.facts dt { color: var(--text-secondary); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

table.data td.actions { white-space: nowrap; text-align: right; }
table.data td.actions button + button { margin-left: 4px; }
@media (max-width: 760px) { table.data td.actions { white-space: normal; text-align: left; } }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; border: 1px solid var(--border); }
.badge.ok { background: color-mix(in srgb, var(--good) 14%, transparent); }
.badge.warn { background: color-mix(in srgb, var(--warning) 22%, transparent); }
.badge.off { color: var(--text-secondary); background: var(--surface-2); }

button.danger { background: var(--critical); border-color: var(--critical); color: #fff; font-weight: 600; }
button.danger:hover { filter: brightness(1.08); background: var(--critical); }
button.danger-ghost { background: transparent; color: var(--critical); border-color: color-mix(in srgb, var(--critical) 45%, transparent); }
button.danger-ghost:hover { background: color-mix(in srgb, var(--critical) 10%, transparent); }

.dialog-form { min-width: min(360px, calc(100vw - 72px)); }
.dialog-form .field input, .dialog-form .field select { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.secret-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.secret {
  font: 600 16px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.04em;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
  user-select: all;
}

/* --- Configuration du magasin ------------------------------------------- */

.page.config { padding-bottom: 96px; }
.status-card { display: flex; gap: 12px 24px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.status-card #check { flex: 1 1 420px; min-width: 0; }
.check-line { padding-left: 12px; border-left: 3px solid var(--muted); margin: 0; }
.check-line.ok { border-left-color: var(--good); }
.check-line.bad { border-left-color: var(--critical); }
.warnings { margin: 8px 0 0; padding-left: 30px; font-size: 13px; color: var(--text-secondary); }
.warnings li::marker { content: "▲  "; color: var(--serious); font-size: 11px; }
.facts.inline { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; }
.facts.inline dt::after { content: " :"; }
.facts.inline dd { margin-right: 4px; }
.facts.inline dt, .facts.inline dd { display: inline; }

.savebar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  background: var(--surface-1); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 8px 10px 8px 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  max-width: calc(100vw - 32px); font-size: 13px;
}
.savebar span { font-weight: 600; margin-right: 4px; }

.section-intro { margin: 0 0 12px; }
.check.line { display: flex; align-items: flex-start; margin: 4px 0 10px; color: var(--text-primary); }
.check.line input { margin-top: 3px; }
.hint.block { display: block; }
.check-list { display: flex; flex-wrap: wrap; gap: 0 16px; }
.check-list .check.line { margin: 2px 0; }

.days { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.days button { padding: 3px 0; width: 44px; font-size: 12.5px; background: transparent; }
.days button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 2px 1px 10px; font-size: 12.5px; color: var(--text-primary); }
.chip-x { border: 0; background: transparent; padding: 0 6px; line-height: 1.3; font-size: 15px; border-radius: 999px; color: var(--text-secondary); }
.chip-add { display: inline-flex; gap: 6px; align-items: center; }

.inline-fields { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--text-secondary); }
.card input:not([type="checkbox"]), .card select, dialog input:not([type="checkbox"]), dialog select {
  font-size: 13.5px; color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--axis); border-radius: 6px; padding: 4px 7px; min-width: 0;
}
.field input:not([type="checkbox"]), .field select { padding: 6px 8px; font-size: 14px; }
input.w-num { width: 74px; }
input.w-code { width: 90px; }
input.w-name { width: 130px; }
table.form-table td { vertical-align: middle; }
table.form-table input[type="text"]:not(.w-name):not(.w-code) { width: 100%; min-width: 140px; }
table.data.compact th { color: var(--text-primary); font-weight: 400; font-size: 13px; }
table.data.compact td, table.data.compact th { vertical-align: middle; }

.need-card .need-row + .need-row { border-top: 1px solid var(--grid); }
.need-row { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.need-when { display: flex; flex-direction: column; gap: 6px; }
.need-card > .actions, .card > .actions { margin-top: 8px; align-items: center; }

.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px solid var(--grid); color: var(--text-primary); font-size: 13px; }
.plain-list li > span:first-child { min-width: 260px; }

/* Fiche salarié */
.fiche-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.fiche-head h2 { margin: 0; font-size: 18px; }
.fiche-head .spacer { flex: 1; }
.fiche { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; align-items: start; }
.fiche > .card:nth-last-child(-n+3) { grid-column: 1 / -1; }
@media (max-width: 820px) { .fiche { grid-template-columns: minmax(0, 1fr); } }
button.link { all: unset; cursor: pointer; color: var(--accent); font-weight: 600; }
button.link:hover { text-decoration: underline; }
button.link:focus-visible { outline: 2px solid var(--focus); border-radius: 3px; }

.item-list { list-style: none; margin: 0 0 8px; padding: 0; }
.item-list li { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.item-list li > span:nth-child(2) { flex: 1; min-width: 0; }

/* Étiquettes : la forme (bordure) porte le type, pas seulement la couleur. */
.tag, .cal-tag { display: inline-block; font-size: 11.5px; font-weight: 600; line-height: 1.5; padding: 0 6px; border-radius: 4px; white-space: nowrap; border: 1px solid var(--axis); background: var(--surface-2); color: var(--text-primary); }
.tag.absence { background: color-mix(in srgb, var(--series-1) 18%, var(--surface-1)); border-color: color-mix(in srgb, var(--series-1) 55%, transparent); }
.tag.indispo { background: color-mix(in srgb, var(--series-2) 18%, var(--surface-1)); border-color: color-mix(in srgb, var(--series-2) 55%, transparent); border-style: dashed; }
.tag.wish { background: transparent; border-style: dotted; }
.tag.lock { background: var(--surface-1); border-color: var(--text-secondary); }
.tag.rot { background: color-mix(in srgb, var(--series-3) 16%, var(--surface-1)); border-color: color-mix(in srgb, var(--series-3) 60%, transparent); border-width: 1px 1px 1px 3px; }
table.calendar td.rot { background: color-mix(in srgb, var(--series-3) 12%, var(--surface-1)); }

/* Roulement des samedis (onglet Magasin) */
.rot-list { margin: 8px 0; padding-left: 26px; }
.rot-list li { padding: 3px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.rot-list li::marker { color: var(--text-secondary); }
.rot-list li > * { margin-right: 8px; vertical-align: middle; }
.rot-name { display: inline-block; min-width: 170px; font-weight: 600; }

/* Calendrier */
.cal-nav { display: inline-flex; align-items: center; gap: 8px; }
.cal-month { min-width: 130px; text-align: center; text-transform: capitalize; }
.cal-wrap { max-height: 70vh; overflow: auto; }
table.calendar { width: auto; min-width: 100%; }
table.calendar thead th.day { text-align: center; font-weight: 600; min-width: 38px; padding: 3px 2px; line-height: 1.2; }
table.calendar thead th.day .dl { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-secondary); }
table.calendar thead th.today { box-shadow: inset 0 -2px 0 var(--accent); }
table.calendar th.emp { min-width: 140px; white-space: nowrap; }
table.calendar td.cal { text-align: center; padding: 3px 2px; cursor: pointer; height: 34px; vertical-align: middle; }
table.calendar td.cal:hover, table.calendar td.cal:focus-visible { background: var(--surface-2); }
table.calendar td.cal:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
table.calendar td.closed { cursor: default; }
table.calendar td.absence { background: color-mix(in srgb, var(--series-1) 14%, var(--surface-1)); }
table.calendar td.indispo { background: color-mix(in srgb, var(--series-2) 12%, var(--surface-1)); }
table.calendar .cal-tag { font-size: 10.5px; padding: 0 3px; border: 0; background: transparent; display: block; }
table.calendar .cal-mark { color: var(--muted); font-size: 18px; line-height: 0.6; }
.swatch-closed { display: inline-block; width: 16px; height: 12px; border: 1px solid var(--border); border-radius: 3px; background: repeating-linear-gradient(45deg, transparent 0 4px, var(--axis) 4px 5px); }

dialog.wide-dialog { max-width: min(560px, calc(100vw - 32px)); width: 560px; }
dialog.wide-dialog h3 { margin-top: 14px; }

@media (max-width: 640px) {
  .plain-list li > span:first-child { min-width: 0; }
  .savebar { left: 16px; right: 16px; transform: none; }
}
.field input[type="checkbox"], .field input[type="radio"] { width: auto; }
table.data.compact .check.line { margin: 0; }

/* --- Plannings ------------------------------------------------------------- */

.plan-head .link { margin-bottom: 8px; display: inline-block; }
.plan-head h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calc-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; font-size: 13px; }
.progress { flex: 1 0 100%; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width 0.6s linear; }
.banners { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.banners .note ul { margin: 6px 0; padding-left: 20px; font-size: 13px; }
.banners .note .actions { align-items: center; margin-top: 6px; }
.note.bad { border-left-color: var(--critical); background: color-mix(in srgb, var(--critical) 10%, transparent); }

.problems .pb-group + .pb-group { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--grid); }
.problems .pb-group h3 { margin: 0 0 4px; font-size: 13.5px; }
.problems .pb-group.ok { font-size: 13px; color: var(--text-secondary); }
.pb-ok { color: var(--good); font-weight: 600; }
.problem-list { margin: 0; padding-left: 20px; font-size: 13px; }
.problem-list li { margin: 2px 0; }
.problem-list li::marker { color: var(--muted); }
.pb-group.bad .problem-list li::marker, .problem-list.bad li::marker { content: "✖  "; color: var(--critical); font-size: 11px; }
.pb-group.warn .problem-list li::marker { content: "▼  "; color: var(--serious); font-size: 11px; }

.plan-weeks h3 { margin: 18px 0 6px; }
.plan-weeks .legend { margin: 0 0 6px; }
.swatch.bad-swatch { background: color-mix(in srgb, var(--critical) 22%, var(--surface-1)); border: 1px solid var(--critical); }
table.plan-grid td.pc.ro { cursor: default; }
table.plan-grid td.pc.bad, table.plan-grid td.hours.bad {
  background: color-mix(in srgb, var(--critical) 13%, var(--surface-1));
  box-shadow: inset 0 0 0 2px var(--critical);
}
table.plan-grid td.hours { font-size: 12px; }
table.plan-grid td.hours.bad .d { color: var(--critical); font-weight: 600; }
table.plan-grid td.hours.off-balance:not(.bad) .d { color: var(--text-primary); font-weight: 600; }
table.plan-grid th.emp .r.new { color: var(--serious); font-weight: 600; }
table.plan-grid tr.day-notes th, table.plan-grid tr.day-notes td { font-size: 11.5px; color: var(--text-secondary); background: var(--surface-2); }
table.plan-grid tr.day-notes td.miss { color: var(--text-primary); font-weight: 600; cursor: help; }
table.plan-grid tr.day-notes td.miss::first-letter { color: var(--critical); }
table.plan-grid tr.day-notes td.okc { color: var(--good); }
table.plan-grid tr.day-notes td.miss.bad { background: color-mix(in srgb, var(--critical) 13%, var(--surface-1)); }
dialog.history-dialog { width: 760px; max-width: calc(100vw - 32px); max-height: 85vh; }
.history-dialog .journal { max-height: 46vh; overflow: auto; }

.print-only { display: none; }

@media print {
  @page { size: A4 landscape; margin: 9mm; }
  :root { color-scheme: light; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .topbar, .status-card, .tabs, .savebar, .toasts, .no-print, dialog { display: none !important; }
  .page { max-width: none; padding: 0; margin: 0; }
  .print-only { display: block; }
  .print-head { margin: 0 0 3mm; font-size: 11pt; }
  .print-week { break-after: page; }
  .print-week:last-child { break-after: auto; }
  .table-wrap { overflow: visible; }
  table.grid { font-size: 8.5pt; border-color: #888; border-radius: 0; }
  table.grid th, table.grid td { border-color: #bbb; padding: 2px 4px; }
  table.grid thead th, table.grid th.emp { position: static; }
  table.grid td.pc { min-width: 0; }
  table.grid td.work, table.plan-grid td.pc.bad, table.plan-grid tr.day-notes td {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .l2 { color: #333; }
  .vb { display: none; }
}
