:root {
  --bg: #f0f4f8;
  --sidebar-bg: #1a3a5c;
  --sidebar-text: #c8daea;
  --sidebar-active: #2d7d9a;
  --card: #ffffff;
  --card-border: #dde4ee;
  --primary: #1a3a5c;
  --primary-dark: #0f2540;
  --primary-light: #b8cde0;
  --secondary: #2d7d9a;
  --accent: #0d9488;
  --text: #0f172a;
  --text-muted: #64748b;
  --danger: #dc2626;
  --hot: #dc2626;
  --active-col: #2d7d9a;
  --possible: #d97706;
  --someday: #64748b;
  --done-color: #0d9488;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 8px rgba(15,37,64,0.08);
  --shadow-md: 0 4px 20px rgba(15,37,64,0.12);
  --transition: 0.15s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
button, a, .task-check, .subtask-check, .nav-btn, .filter-btn { touch-action: manipulation; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
}

#app { display: flex; height: 100vh; overflow: hidden; }

/* SIDEBAR */
#sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  gap: 2px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 16px;
  border-bottom: 1px solid rgba(200,218,234,0.12);
  margin-bottom: 6px;
}

.logo-img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; }
.logo-text { font-size: 13px; font-weight: 800; color: var(--sidebar-text); line-height: 1.2; }
.logo-sub { font-size: 10px; font-weight: 600; color: rgba(200,218,234,0.5); text-transform: uppercase; letter-spacing: 0.5px; }

.nav-items { display: flex; flex-direction: column; gap: 1px; flex: 1; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: rgba(200,218,234,0.65);
  font-family: 'Nunito', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}
.nav-btn:hover { background: rgba(200,218,234,0.08); color: var(--sidebar-text); }
.nav-btn.active { background: var(--secondary); color: white; }

/* Desktop: icon + label inline */
.nav-icon { font-size: 15px; }
.nav-label { } /* normal text desktop */

.sidebar-footer { border-top: 1px solid rgba(200,218,234,0.1); padding-top: 10px; }

/* MAIN */
#main { flex: 1; overflow-y: auto; padding: 28px 32px; }

.tab { display: none; }
.tab.active { display: block; }

.tab-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.tab-title { font-size: 24px; font-weight: 800; color: var(--text); }
.tab-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; font-weight: 600; }
.tab-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* BUTTONS */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary.small { padding: 5px 10px; font-size: 12px; }

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover { border-color: var(--secondary); color: var(--secondary); }
.btn-secondary.small { padding: 4px 9px; font-size: 12px; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.btn-ghost:hover { background: var(--card-border); color: var(--text); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: none;
  padding: 4px 7px;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.btn-danger:hover { background: #fef2f2; }

/* FILTER BAR */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

/* Pastille P (projet) / L (libre) dans la ligne badges */
.scope-badge {
  font-size: 9px; font-weight: 800; padding: 1px 5px; border-radius: 20px;
  flex-shrink: 0; letter-spacing: 0.3px;
}
.scope-project { background: #dbeafe; color: #1d4ed8; }
.scope-libre   { background: #dcfce7; color: #15803d; }

/* Boutons d'action avec label texte (desktop) / icône (mobile) */
.task-act {
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  background: white;
}
.task-act.btn-danger  { border-color: transparent; background: transparent; }
.task-act.btn-ghost   { background: white; color: var(--text-muted); }
.task-act.btn-ghost:hover { background: var(--bg); color: var(--text); border-color: var(--card-border); }
.act-icon  { display: none; }
.act-label { display: inline; }

/* Idées — label texte des boutons action */
.idea-label { display: inline; }

/* Multi-label filter */
.filter-labels-bar {
  display: flex; gap: 4px; align-items: center; flex-wrap: wrap;
}
.filter-label-btn {
  border: 2px solid transparent;
  border-radius: 20px; padding: 3px 10px;
  font-family: 'Nunito', sans-serif; font-size: 11px; font-weight: 700;
  cursor: pointer; color: white; opacity: 0.4;
  transition: var(--transition); touch-action: manipulation;
}
.filter-label-btn.active { opacity: 1; border-color: rgba(0,0,0,0.25); box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.filter-label-btn:hover { opacity: 0.7; }

/* Label filter dropdown (mobile uniquement, rendu par JS) */
.label-dropdown-wrap { position: relative; }
.label-dropdown-trigger {
  background: white; border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 4px 8px;
  font-family: 'Nunito', sans-serif; font-size: 10px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; flex-wrap: wrap;
  gap: 3px; max-width: 130px; min-height: 28px; touch-action: manipulation;
  color: var(--text);
}
.label-dropdown-trigger.has-selection { border-color: var(--secondary); }
.label-dropdown-panel {
  position: absolute; top: calc(100% + 4px); right: 0;
  background: white; border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  z-index: 100; min-width: 160px; overflow: hidden;
}
.label-dropdown-item {
  display: flex; align-items: center; width: 100%; text-align: left;
  padding: 8px 12px; background: none; border: none;
  border-bottom: 1px solid var(--bg);
  font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 600;
  cursor: pointer; touch-action: manipulation; transition: var(--transition);
}
.label-dropdown-item:last-child { border-bottom: none; }
.label-dropdown-item:hover { background: var(--bg); }
.label-dropdown-item.active { font-weight: 800; color: var(--secondary); }

/* Tasks filter bar — desktop : 1 ligne, mobile : 2 lignes */
#tasks-filter-bar {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}
/* Sur desktop, filter-row est transparent : ses enfants remontent dans le flex parent */
.filter-row { display: contents; }

.filter-group { display: flex; gap: 3px; background: white; border-radius: var(--radius-sm); padding: 3px; border: 1px solid var(--card-border); }

.filter-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 5px 11px;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.filter-btn:hover { color: var(--text); }
.filter-btn.active { background: var(--primary); color: white; }

.filter-select {
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: white;
  cursor: pointer;
  outline: none;
}

/* TASK LIST */
.task-list { display: flex; flex-direction: column; gap: 8px; }

.task-card {
  background: white;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  cursor: pointer;
}
.task-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.task-card.done-card { opacity: 0.5; }

.task-card-top { display: flex; align-items: flex-start; gap: 10px; }

.task-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--card-border);
  background: white;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 10px;
}
.task-check:hover { border-color: var(--secondary); }
.task-check.checked { background: var(--done-color); border-color: var(--done-color); color: white; }

.task-info { flex: 1; min-width: 0; }
.task-title { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.4; }
.task-card.done-card .task-title { text-decoration: line-through; color: var(--text-muted); }

.task-meta {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
  flex-wrap: nowrap; overflow: hidden;
}

.temporality-badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; letter-spacing: 0.2px; }
.temp-hot      { background: #fef2f2; color: var(--hot); }
.temp-active   { background: #eff6ff; color: var(--active-col); }
.temp-possible { background: #fffbeb; color: var(--possible); }
.temp-someday  { background: #f8fafc; color: var(--someday); }

.space-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

.label-badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; color: white; }

/* Status badges */
.status-badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 20px; cursor: pointer; transition: var(--transition); }
.status-badge:hover { opacity: 0.8; }
.status-todo        { background: #f1f5f9; color: #475569; }
.status-in-progress { background: #eff6ff; color: #1d4ed8; }
.status-waiting     { background: #fffbeb; color: #b45309; }
.status-done-badge  { background: #f0fdf4; color: #15803d; }

/* Status picker popup */
.status-picker-popup {
  background: white;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 160px;
  overflow: hidden;
  z-index: 500;
}
.status-pick-item {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-pick-item:hover { background: var(--bg); }
.status-pick-item.active { background: var(--primary); color: white; }

.task-desc-inline {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 900px;
}

/* Bouton sélection batch (carré, à gauche du rond) */
.task-sel {
  width: 16px; height: 16px;
  border: 2px solid var(--card-border);
  border-radius: 3px;
  background: white;
  cursor: pointer;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; color: transparent;
  transition: var(--transition);
  opacity: 0;
  padding: 0;
  touch-action: manipulation;
}
.task-card:hover .task-sel { opacity: 1; }
.task-sel.sel-active { opacity: 1; background: var(--secondary); border-color: var(--secondary); color: white; }
.task-selected { background: #f0f7ff !important; border-color: var(--secondary) !important; }

/* Barre batch fixe en bas */
#batch-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--primary); color: white;
  padding: 10px 16px; gap: 8px;
  align-items: center; flex-wrap: wrap;
  z-index: 200;
  box-shadow: 0 -4px 20px rgba(15,37,64,0.25);
}
.batch-count { font-size: 13px; font-weight: 700; margin-right: 4px; }
.batch-select {
  border: none; border-radius: var(--radius-sm);
  padding: 5px 10px; font-family: 'Nunito', sans-serif;
  font-size: 12px; font-weight: 700; cursor: pointer;
  background: rgba(255,255,255,0.15); color: white;
  outline: none;
}
.batch-select option { background: var(--primary); color: white; }
.batch-apply {
  background: white; color: var(--primary);
  border: none; border-radius: var(--radius-sm);
  padding: 5px 14px; font-family: 'Nunito', sans-serif;
  font-size: 12px; font-weight: 800; cursor: pointer;
  touch-action: manipulation;
}
.batch-today {
  background: rgba(255,220,100,0.15); color: rgba(255,220,100,0.7);
  border: 1px solid rgba(255,220,100,0.3); border-radius: var(--radius-sm);
  padding: 5px 10px; font-family: 'Nunito', sans-serif;
  font-size: 14px; font-weight: 800; cursor: pointer;
  touch-action: manipulation; transition: var(--transition);
}
.batch-today.batch-today-active {
  background: rgba(255,220,60,0.35); color: #ffe169;
  border-color: rgba(255,220,60,0.7);
  box-shadow: 0 0 0 2px rgba(255,220,60,0.25);
}
.batch-cancel {
  background: transparent; color: rgba(255,255,255,0.6);
  border: none; font-size: 16px; cursor: pointer;
  padding: 4px 6px; border-radius: var(--radius-sm);
  touch-action: manipulation;
}
.sort-control { display: flex; align-items: center; gap: 2px; margin-left: auto; flex-shrink: 0; }
.filter-sort-select {
  border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 2px 4px; font-family: 'Nunito', sans-serif;
  font-size: 11px; font-weight: 700; cursor: pointer;
  background: var(--bg); color: var(--text-muted);
  outline: none; max-width: 100px; touch-action: manipulation;
}
.sort-dir-btn {
  border: 1px solid var(--primary); border-radius: var(--radius-sm);
  padding: 2px 6px; font-size: 11px; font-weight: 800; cursor: pointer;
  background: var(--bg); color: var(--primary);
  touch-action: manipulation; line-height: 1;
}
@media (max-width: 768px) {
  .filter-sort-select { font-size: 10px; max-width: 76px; padding: 2px 3px; }
  .sort-dir-btn { font-size: 10px; padding: 2px 4px; }
}

.task-actions { display: flex; gap: 1px; opacity: 0; transition: var(--transition); }
.task-card:hover .task-actions { opacity: 1; }

/* SUBTASKS */
.subtasks-section { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--card-border); }
.subtask-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.subtask-check {
  width: 16px; height: 16px; border-radius: 4px; border: 2px solid var(--card-border);
  background: white; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 9px; transition: var(--transition);
}
.subtask-check:hover { border-color: var(--secondary); }
.subtask-check.checked { background: var(--done-color); border-color: var(--done-color); color: white; }
.subtask-title { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.subtask-title.done { text-decoration: line-through; color: var(--text-muted); }

/* NOTES */
.notes-section { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.note-block {
  background: #f8fafc;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
  border-left: 3px solid var(--primary-light);
  position: relative;
}
.note-block .note-delete { position: absolute; top: 5px; right: 5px; opacity: 0; transition: var(--transition); }
.note-block:hover .note-delete { opacity: 1; }
.note-block-clickable { cursor: pointer; }
.note-block-clickable:hover { background: #eef2f7; }

/* Financial table */
.financial-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.financial-table th {
  text-align: left; padding: 4px 8px;
  color: var(--text-muted); font-weight: 700; font-size: 11px;
  border-bottom: 1px solid var(--card-border); background: var(--bg);
}
.financial-table td { padding: 5px 8px; border-bottom: 1px solid #f1f5f9; font-weight: 600; }
.financial-table tr:last-child td { border-bottom: none; }
.financial-total { font-size: 12px; font-weight: 800; color: var(--secondary); text-align: right; margin-top: 5px; }

/* Financial builder — on utilise une vraie table pour garantir l'alignement */
.financial-builder { border: 1.5px solid var(--card-border); border-radius: var(--radius-sm); overflow: hidden; }
.financial-builder table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.financial-builder thead th {
  background: var(--bg);
  padding: 5px 10px;
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--card-border);
}
.financial-builder thead th:nth-child(1) { width: 30%; }
.financial-builder thead th:nth-child(2) { width: 15%; }
.financial-builder thead th:nth-child(3) { width: 20%; }
.financial-builder thead th:nth-child(4) { width: auto; }
.financial-builder thead th:nth-child(5) { width: 32px; }

.financial-builder tbody tr { border-bottom: 1px solid var(--card-border); }
.financial-builder tbody tr:last-child { border-bottom: none; }
.financial-builder tbody td { padding: 0; }
.financial-builder tbody td input {
  width: 100%;
  border: none;
  border-right: 1px solid var(--card-border);
  padding: 7px 10px;
  font-family: 'Nunito', sans-serif;
  font-size: 13px; font-weight: 600;
  outline: none; background: white;
  display: block;
}
.financial-builder tbody td:last-child input,
.financial-builder tbody td.fin-del-cell { border-right: none; }
.fin-del {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 13px; width: 32px; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.fin-del:hover { color: var(--danger); }
.financial-builder-add { padding: 5px; text-align: center; }

/* PROJECTS GRID */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.project-card {
  background: white; border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); cursor: pointer; transition: var(--transition);
}
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.project-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.project-title { font-size: 15px; font-weight: 800; color: var(--text); }
.project-status { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; flex-shrink: 0; }
.status-active  { background: #f0fdf4; color: #15803d; }
.status-frozen  { background: #eff6ff; color: #1d4ed8; }
.status-done    { background: #faf5ff; color: #7c3aed; }
.project-progress { height: 5px; background: var(--card-border); border-radius: 3px; margin: 8px 0; overflow: hidden; }
.project-progress-bar { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--secondary), var(--accent)); transition: width 0.4s ease; }
.project-description { font-size: 12px; color: var(--text-muted); margin: 5px 0; line-height: 1.5; }
.project-meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }

/* MEMOS GRID */
.memos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.memo-card {
  background: white; border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); cursor: pointer; transition: var(--transition);
}
.memo-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.memo-title { font-size: 14px; font-weight: 800; margin-bottom: 6px; }
.memo-content { font-size: 12px; color: var(--text-muted); line-height: 1.6; white-space: pre-wrap; word-break: break-word; overflow-y: auto; }
.memo-labels { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }

/* IDEAS */
.ideas-list { display: flex; flex-direction: column; gap: 8px; }
.idea-card {
  background: white; border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow); display: flex; align-items: flex-start; gap: 10px; transition: var(--transition);
}
.idea-card:hover { box-shadow: var(--shadow-md); }
.idea-icon { font-size: 20px; flex-shrink: 0; }
.idea-info { flex: 1; }
.idea-title { font-size: 14px; font-weight: 700; }
.idea-desc { font-size: 12px; color: var(--text-muted); margin-top: 3px; line-height: 1.5; }
.idea-labels { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.idea-actions { display: flex; gap: 4px; opacity: 0; transition: var(--transition); flex-shrink: 0; }
.idea-card:hover .idea-actions { opacity: 1; }

/* REMINDERS */
.reminders-list { display: flex; flex-direction: column; gap: 8px; }
.reminder-card {
  background: white; border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px; transition: var(--transition);
}
.reminder-card:hover { box-shadow: var(--shadow-md); }
.reminder-card.expired { border-left: 3px solid var(--danger); }
.reminder-card.expiring-soon { border-left: 3px solid var(--possible); }
.reminder-card.done-card { opacity: 0.45; }
.reminder-info { flex: 1; }
.reminder-title { font-size: 14px; font-weight: 700; }
.reminder-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.reminder-date { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.date-expired { background: #fef2f2; color: var(--danger); }
.date-soon    { background: #fffbeb; color: var(--possible); }
.date-ok      { background: #f0fdf4; color: #15803d; }
.date-none    { background: var(--bg); color: var(--text-muted); }

/* DEBTS */
.debts-summary { display: flex; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.debt-summary-card {
  background: white; border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 12px 18px;
  box-shadow: var(--shadow); flex: 1; min-width: 140px;
}
.debt-summary-label { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
.debt-summary-amount { font-size: 20px; font-weight: 800; margin-top: 3px; }
.i-owe-color   { color: var(--danger); }
.they-owe-color { color: var(--done-color); }
.debts-list { display: flex; flex-direction: column; gap: 8px; }
.debt-card { background: white; border: 1px solid var(--card-border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.debt-card-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.debt-direction { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 20px; }
.debt-i-owe    { background: #fef2f2; color: var(--danger); }
.debt-they-owe { background: #f0fdf4; color: #15803d; }
.debt-person   { font-size: 15px; font-weight: 800; }
.debt-amount   { font-size: 14px; font-weight: 700; margin-left: auto; }
.debt-unknown  { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-left: auto; }
.debt-context  { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.debt-progress-section { margin-top: 8px; }
.debt-progress-bar-wrap { height: 5px; background: var(--card-border); border-radius: 3px; margin: 5px 0; }
.debt-progress-bar { height: 100%; border-radius: 3px; background: var(--done-color); }
.debt-progress-text { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.debt-actions { margin-top: 8px; display: flex; gap: 7px; }

/* DEBT PAYMENTS LIST */
.debt-payments-list { margin: 8px 0 4px; display: flex; flex-direction: column; gap: 4px; }
.debt-payment-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 6px;
  background: #f0f7ff; border: 1px solid #dbeafe;
  font-size: 12px; cursor: pointer; transition: var(--transition);
}
.debt-payment-row:hover { background: #dbeafe; }
.debt-payment-icon { flex-shrink: 0; font-size: 11px; }
.debt-payment-amount { font-weight: 800; color: var(--done-color); flex-shrink: 0; }
.debt-payment-note { color: var(--text-muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.debt-payment-date { color: var(--text-muted); font-size: 10px; flex-shrink: 0; margin-left: auto; }

/* EMPTY STATE */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 20px; color: var(--text-muted); gap: 10px; }
.empty-icon { font-size: 44px; }
.empty-state p { font-size: 14px; font-weight: 600; }

/* SETTINGS */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-card { background: white; border: 1px solid var(--card-border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.settings-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.settings-card h2 { font-size: 16px; font-weight: 800; }
.label-item { display: flex; align-items: center; gap: 9px; padding: 7px 0; border-bottom: 1px solid var(--bg); }
.label-item:last-child { border-bottom: none; }
.color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }

/* MODAL */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,37,64,0.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: white; border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: modal-in 0.18s ease;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-title { font-size: 18px; font-weight: 800; margin-bottom: 18px; color: var(--primary); }

.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.form-input, .form-textarea, .form-select {
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-family: 'Nunito', sans-serif; font-size: 14px; font-weight: 600;
  color: var(--text); background: white; outline: none; transition: var(--transition); width: 100%;
}
.form-input:focus, .form-textarea:focus, .form-select:focus { border-color: var(--secondary); }
.form-textarea { min-height: 80px; resize: vertical; line-height: 1.6; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

.labels-picker { display: flex; flex-wrap: wrap; gap: 5px; }
.label-pick-btn {
  border: 2px solid transparent;
  border-radius: 20px; padding: 3px 11px;
  font-family: 'Nunito', sans-serif; font-size: 12px; font-weight: 700;
  cursor: pointer; color: white; transition: var(--transition); opacity: 0.45;
}
.label-pick-btn.selected { opacity: 1; border-color: rgba(0,0,0,0.2); }
.label-pick-btn:hover { opacity: 0.75; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* Dirty warning */
.dirty-warning {
  background: #fffbeb; border: 1px solid #fde68a;
  border-radius: var(--radius-sm); padding: 8px 12px;
  font-size: 12px; font-weight: 600; color: #92400e;
  margin-bottom: 12px; display: none;
}
.dirty-warning.show { display: block; }

/* DRAWER */
.drawer-overlay { position: fixed; inset: 0; background: rgba(15,37,64,0.3); display: none; z-index: 90; }
.drawer-overlay.open { display: block; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 540px;
  background: white; box-shadow: -4px 0 30px rgba(15,37,64,0.12);
  overflow-y: auto; padding: 24px;
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; }
.drawer-title { font-size: 20px; font-weight: 800; line-height: 1.3; flex: 1; }
.drawer-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); padding: 3px; border-radius: 6px; transition: var(--transition); }
.drawer-close:hover { background: var(--bg); color: var(--text); }
.drawer-section { margin-bottom: 22px; }
.drawer-section-title {
  font-size: 11px; font-weight: 800; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: center;
}

/* TOAST */
.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--primary); color: white;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700; z-index: 999;
  transition: transform 0.25s ease; pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* MISC */
.add-inline { display: flex; gap: 7px; margin-top: 7px; }
.add-inline input {
  flex: 1; border: 1.5px solid var(--card-border);
  border-radius: var(--radius-sm); padding: 6px 11px;
  font-family: 'Nunito', sans-serif; font-size: 13px; font-weight: 600; outline: none;
}
.add-inline input:focus { border-color: var(--secondary); }

.expand-toggle {
  background: none; border: none; color: var(--text-muted);
  font-size: 12px; font-weight: 700; cursor: pointer; padding: 3px 0;
  display: flex; align-items: center; gap: 4px; font-family: 'Nunito', sans-serif;
}
.expand-toggle:hover { color: var(--secondary); }

.progress-input { display: flex; align-items: center; gap: 10px; }
.progress-input input[type=range] { flex: 1; accent-color: var(--secondary); }
.progress-input span { font-size: 13px; font-weight: 700; color: var(--secondary); width: 36px; }

/* Daily */
.daily-card {
  background: white; border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 10px 14px;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 10px; transition: var(--transition);
}
.daily-card:hover { box-shadow: var(--shadow-md); }
.daily-card.done-card { opacity: 0.45; }
.daily-card.done-card .daily-title { text-decoration: line-through; }
.daily-title { flex: 1; font-size: 13px; font-weight: 700; }
.daily-ephemeral-badge { font-size: 10px; color: var(--text-muted); font-weight: 700; background: var(--bg); border-radius: 20px; padding: 2px 7px; }
.daily-source { font-size: 10px; color: var(--secondary); font-weight: 700; }
.daily-actions { display: flex; gap: 3px; opacity: 0; transition: var(--transition); }
.daily-card:hover .daily-actions { opacity: 1; }


/* ═══════════════════════════════════════
   MOBILE (max-width: 768px)
   Nav horizontale en haut, tabs full-height, liste scrollable
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
  body { overflow: hidden; }
  #app { flex-direction: column; height: 100vh; overflow: hidden; }

  /* ── Sidebar → barre horizontale en haut ── */
  #sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: stretch;
    padding: 4px 4px 2px;
    gap: 0;
    flex-shrink: 0;
  }
  .sidebar-header { display: none; }

  .nav-items {
    flex-direction: row;
    flex: 1;
    gap: 0;
    overflow: visible;
  }
  .nav-btn {
    flex: 1;
    flex-direction: column;
    gap: 0;
    padding: 5px 2px 4px;
    min-width: 0;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
  }
  .nav-icon { font-size: 17px; line-height: 1; }
  .nav-label {
    font-size: 8px; font-weight: 700; line-height: 1.3;
    text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  }

  .sidebar-footer {
    border-top: none; padding-top: 0;
    display: flex; flex-direction: row; gap: 0; flex-shrink: 0;
    border-left: 1px solid rgba(200,218,234,0.2);
    padding-left: 2px; margin-left: 2px;
  }
  .sidebar-footer .nav-btn { flex: 1; min-width: 0; padding: 5px 3px 4px; }
  .sidebar-footer .nav-icon { font-size: 15px; }
  .sidebar-footer .nav-label { font-size: 7px; }

  /* ── Main : pas de scroll global — chaque tab gère le sien ── */
  #main {
    flex: 1; min-height: 0;
    overflow-y: hidden;
    padding: 0;
    display: flex; flex-direction: column;
  }

  /* Chaque tab actif = flex colonne, seule la liste scrolle */
  .tab.active {
    display: flex !important;
    flex-direction: column;
    flex: 1; min-height: 0;
    overflow: hidden;
    padding: 10px 12px 0;
  }

  .tab-title { font-size: 20px; }
  .tab-header { flex-shrink: 0; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
  .tab-actions .btn-primary,
  .tab-actions .btn-secondary { font-size: 11px; padding: 6px 10px; }

  /* Listes scrollables */
  .task-list, .projects-grid, .memos-grid,
  .ideas-list, .reminders-list, .debts-list {
    flex: 1 !important; min-height: 0;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 80px;
  }
  /* Collapse liste vide pour laisser apparaître l'empty-state */
  .task-list:empty, .projects-grid:empty, .memos-grid:empty,
  .ideas-list:empty, .reminders-list:empty, .debts-list:empty {
    flex: 0 !important; min-height: 0; padding-bottom: 0;
  }
  .debts-summary { flex-shrink: 0; margin-bottom: 10px; }
  .empty-state { flex-shrink: 0; padding: 30px 20px; }
  .settings-card { flex: 1; overflow-y: auto; min-height: 0; }

  /* ── Filtres ── */
  .filter-bar { flex-shrink: 0; margin-bottom: 8px; }
  #tasks-filter-bar {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
    flex-shrink: 0;
    margin-bottom: 8px;
  }

  /* Filter-row : 1 ligne scrollable par rangée */
  .filter-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 4px !important;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
    width: 100%;
  }
  .filter-row::-webkit-scrollbar { display: none; }

  /* Ligne 1 : temporalité s'étire pour remplir la largeur */
  #tasks-filter-bar .filter-row:first-child > .filter-group:first-child { flex: 1; }

  /* Ligne 2 : statut en taille naturelle, le reste va au label-filter */
  #tasks-label-filter {
    flex: 1; min-width: 0;
    display: flex; align-items: stretch; gap: 4px;
  }
  /* Wrap du dropdown : flex pour que le trigger s'étire en hauteur */
  .label-dropdown-wrap { display: flex; align-self: stretch; }
  /* Trigger : même hauteur que le filter-group statut, pas de max-width */
  .label-dropdown-trigger {
    max-width: none; flex-shrink: 0;
    align-self: stretch; height: auto;
    display: flex; align-items: center; justify-content: center;
    gap: 4px; white-space: nowrap;
  }

  .filter-group {
    display: inline-flex !important;
    gap: 2px; margin: 0;
  }

  /* Boutons avec icône + micro-texte en colonne */
  .filter-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font-size: 10px;
    padding: 4px 7px;
    white-space: nowrap;
    min-width: 26px;
  }
  .filter-btn .fb-icon { font-size: 13px; line-height: 1.2; }
  .filter-btn .fb-label {
    display: block !important;
    font-size: 7px; line-height: 1; font-weight: 700;
    white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; max-width: 38px;
  }

  /* Sur mobile : icônes seules pour les boutons d'action */
  .act-icon  { display: inline; }
  .act-label { display: none; }
  .task-act  { border: none; background: transparent; padding: 4px 6px; font-size: 13px; }
  .task-act.btn-danger { padding: 3px 5px; }

  /* Idées mobile : cacher le texte des boutons et empiler */
  .idea-label { display: none; }
  .idea-actions {
    flex-direction: column; gap: 2px; flex-shrink: 0;
    align-items: stretch;
  }
  .idea-actions .btn-primary.small,
  .idea-actions .btn-secondary.small { text-align: center; font-size: 14px; padding: 3px 6px; }
  .idea-actions .btn-ghost { font-size: 14px; padding: 3px 5px; }
  .idea-actions .btn-danger { font-size: 14px; padding: 3px 5px; }

  /* ── Task cards ── */
  .task-card { padding: 9px 11px; }
  .task-title { font-size: 13px; }
  .task-meta {
    flex-wrap: nowrap; overflow-x: auto;
    scrollbar-width: none; gap: 4px;
  }
  .task-meta::-webkit-scrollbar { display: none; }
  .temporality-badge, .status-badge, .space-badge, .label-badge {
    font-size: 10px; padding: 1px 6px; white-space: nowrap; flex-shrink: 0;
  }
  .task-desc-inline {
    font-size: 10px; flex: 1; min-width: 0;
    max-width: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .task-sel { opacity: 1; }

  .task-actions, .idea-actions, .daily-actions { opacity: 1; }
  .projects-grid, .memos-grid { grid-template-columns: 1fr; gap: 10px; }
  .settings-grid { grid-template-columns: 1fr; }
  .drawer { width: 100%; padding: 18px 14px 24px; }
  .modal-box { padding: 16px; margin: 8px; max-height: 88vh; }
  .debt-summary-amount { font-size: 17px; }
  .debt-summary-card { min-width: 90px; padding: 10px 11px; }
  .status-picker-popup { min-width: 160px; }
}

@media (max-width: 380px) {
  .nav-icon { font-size: 15px; }
  .nav-label { font-size: 7px; }
}

/* ── SYNC STATUS BADGE (affiché à côté du titre de chaque onglet) ────────── */
.tab-title {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
}
.tab-sync-badge {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin-left: 10px;
  line-height: 1;
  flex-shrink: 0;
}
.sync-icon { font-size: 17px; line-height: 1; }
.sync-text {
  font-size: 7px; font-weight: 800;
  white-space: nowrap; letter-spacing: 0.01em;
}
body.is-offline .tab-sync-badge {
  display: inline-flex;
}
body.is-syncing .tab-sync-badge {
  display: inline-flex;
}
body.is-offline  .sync-text { color: #dc2626; }
body.is-syncing  .sync-text { color: #0d9488; }

/* ── SUBTASK EXPAND BUTTON ──────────────────────────────────────────────── */
.subtask-expand-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px;
  background: var(--primary); color: white;
  border: none; border-radius: 4px; font-size: 11px; font-weight: 800;
  line-height: 1; vertical-align: middle; margin-left: 4px;
  flex-shrink: 0; cursor: pointer; padding: 0;
  transition: var(--transition);
  touch-action: manipulation;
}
.subtask-expand-btn:hover { background: var(--secondary); }

/* ── SUBTASK ROW CLIQUABLE ──────────────────────────────────────────────── */
.subtask-row-clickable { cursor: pointer; border-radius: 6px; padding: 4px 4px; margin: 0 -4px; }
.subtask-row-clickable:hover { background: rgba(26,58,92,0.05); }
.subtask-del-btn { margin-left: auto; flex-shrink: 0; }

/* ── MEMO CONTENT — scrollable sur mobile, complet sur desktop ─────────── */
@media (max-width: 768px) {
  .memo-content { max-height: 220px; }
  .memos-grid { grid-template-columns: 1fr; }
}

/* ── PENDING BADGE (items créés offline, en attente de sync) ─────────────── */
.pending-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 9px; font-weight: 800;
  background: rgba(220,38,38,0.12); color: #dc2626;
  border: 1px solid rgba(220,38,38,0.3);
  border-radius: 20px; padding: 1px 5px;
  vertical-align: middle; white-space: nowrap;
}
