:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #d9dce1;
  --text: #1c2024;
  --muted: #626b75;
  --accent: #2f5fd8;
  --error: #b3261e;
  --error-bg: #fdecea;
  --info-bg: #e8f0fe;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.header-nav {
  display: flex;
  gap: 1rem;
  margin-right: auto;
  margin-left: 1.5rem;
  font-size: 0.9375rem;
}

.header-nav a { color: var(--text); text-decoration: none; }
.header-nav a:hover { text-decoration: underline; }

main {
  max-width: 34rem;
  margin: 2rem auto;
  padding: 0 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: 1.375rem;
}

.message {
  margin: 0 0 1rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.message-info { background: var(--info-bg); }
.message-error { background: var(--error-bg); color: var(--error); }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0 0 1rem;
}

.field label { font-size: 0.875rem; font-weight: 500; }

.field input[type="text"],
.field input[type="email"],
.field input[type="password"] {
  padding: 0.5rem 0.625rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.field input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.field-hint { font-size: 0.8125rem; color: var(--muted); }
.field-error { font-size: 0.8125rem; color: var(--error); }

.actions { margin: 1.25rem 0 0; }

.button-primary,
.button-secondary {
  display: inline-block;
  padding: 0.5rem 1rem;
  font: inherit;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.button-primary { background: var(--accent); color: #fff; }
.button-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }

.secondary-link {
  margin: 1.25rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9375rem;
}

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

.card-wide { max-width: none; }

main:has(.card-wide) { max-width: 60rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Liste des tâches */

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.list-head h1 { margin-bottom: 0; }

.task-counts {
  margin: 0.5rem 0 1.25rem;
  color: var(--muted);
  font-size: 0.9375rem;
}

.filters {
  display: flex;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.filter {
  padding: 0.3125rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.filter-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 500;
}

.search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search label { font-size: 0.875rem; font-weight: 500; }

.search input[type="search"] {
  flex: 1 1 12rem;
  padding: 0.4375rem 0.625rem;
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.search .field-error { flex-basis: 100%; }

.task-shown {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

table.tasks {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

table.tasks th,
table.tasks td {
  padding: 0.5rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.tasks th {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

table.tasks th a { color: inherit; text-decoration: none; }
table.tasks th a:hover { text-decoration: underline; }

.sort-arrow { margin-left: 0.25rem; }

.cell-title a { color: var(--text); text-decoration: none; font-weight: 500; }
.cell-title a:hover { text-decoration: underline; }

.task-done .cell-title a { text-decoration: line-through; color: var(--muted); }

.task-late .cell-due { color: var(--error); font-weight: 500; }

.late-mention {
  display: inline-block;
  margin-left: 0.375rem;
  padding: 0.0625rem 0.375rem;
  font-size: 0.75rem;
  color: var(--error);
  background: var(--error-bg);
  border-radius: 999px;
}

/* Case à cocher de marquage : un bouton, pour basculer en un seul geste et
   sans script. */
.task-toggle {
  width: 1.125rem;
  height: 1.125rem;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: 4px;
  cursor: pointer;
}

.task-toggle[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
}

.task-toggle[aria-checked="true"]::after {
  content: "✓";
  display: block;
  margin-top: -2px;
  color: #fff;
  font-size: 0.8125rem;
  line-height: 1;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.pagination-disabled { color: var(--border); }
.pagination-position { color: var(--muted); }

/* Formulaire de tâche */

.field textarea {
  padding: 0.5rem 0.625rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}

.field select {
  padding: 0.5rem 0.625rem;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.inline-form { display: inline; }

.button-danger {
  padding: 0.5rem 1rem;
  font: inherit;
  color: #fff;
  background: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  cursor: pointer;
}

.link-danger { color: var(--error); }

.delete-target { font-weight: 500; }

/* Tableau de bord */

.counters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0 0 2rem;
  padding: 0;
  list-style: none;
}

.counter {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 0.875rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.counter-value { font-size: 1.75rem; font-weight: 600; line-height: 1.1; }
.counter-label { font-size: 0.8125rem; color: var(--muted); }

.priority-section h2 { margin: 0 0 0.75rem; font-size: 1.0625rem; }

.priority-list,
.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.priority-item,
.task-item { border-bottom: 1px solid var(--border); }

.priority-item a,
.task-item a {
  display: grid;
  gap: 0.5rem;
  align-items: baseline;
  padding: 0.625rem 0.25rem;
  color: inherit;
  text-decoration: none;
}

.priority-item a { grid-template-columns: 1fr auto auto; }
.task-item a { grid-template-columns: 1fr auto auto auto; }

.priority-item a:hover,
.task-item a:hover { background: var(--info-bg); }

.priority-due,
.priority-level,
.task-due,
.task-priority,
.task-status {
  font-size: 0.8125rem;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 32rem) {
  .counters { grid-template-columns: 1fr; }
}
