:root {
  --orange: #eb5c0b;
  --orange-dark: #b84508;
  --blue: #2563eb;
  --blue-soft: #e9f0ff;
  --grey: #50555b;
  --grey-light: #f4f5f7;
  --grey-border: #d9dde3;
  --text: #1f2933;
  --white: #ffffff;
  --danger: #b42318;
  --success: #1f7a4d;
  --warning: #9a6700;
  --shadow: 0 12px 28px rgba(31, 41, 51, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--grey-light);
  color: var(--text);
  line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 1.2rem;
  background: var(--white);
  border-bottom: 1px solid var(--grey-border);
}
.brand { display: flex; align-items: center; gap: .75rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--orange);
  color: var(--white);
  font-weight: 800;
}
.brand small { display: block; color: var(--grey); font-size: .8rem; }
.main-nav { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.main-nav a {
  padding: .65rem .9rem;
  border-radius: 999px;
  color: var(--text);
  font-weight: 600;
}
.main-nav a:hover { background: var(--grey-light); text-decoration: none; }
.main-nav .logout { color: var(--danger); }
.menu-toggle { display: none; }
.container { width: min(1180px, calc(100% - 2rem)); margin: 1.2rem auto 2.5rem; }
.container.narrow { width: min(820px, calc(100% - 2rem)); }
.card {
  background: var(--white);
  border: 1px solid var(--grey-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.hero, .page-title { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.hero h1, .page-title h1 { margin: .1rem 0 .4rem; font-size: clamp(1.7rem, 4vw, 2.5rem); }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; color: var(--orange-dark); font-weight: 800; }
.hero-box { min-width: 220px; background: var(--blue-soft); border-radius: 16px; padding: 1rem; }
.hero-box strong, .hero-box span { display: block; margin-bottom: .4rem; }
.grid { display: grid; gap: 1rem; }
.cards-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric span { display: block; font-size: 2rem; font-weight: 900; color: var(--orange); }
.metric p { margin: .25rem 0 0; color: var(--grey); font-weight: 700; }
.module h2 { margin-top: 0; }
.status, .badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: 999px;
  padding: .3rem .65rem;
  font-size: .82rem;
  font-weight: 800;
  background: var(--grey-light);
  color: var(--grey);
}
.status.done { background: #eaf7ef; color: var(--success); }
.status.later { background: var(--blue-soft); color: var(--blue); }
.status.danger { background: #ffeceb; color: var(--danger); }
.badge { background: var(--blue-soft); color: var(--blue); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 44px;
  padding: .7rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--grey-border);
  background: var(--white);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; background: var(--grey-light); }
.btn-primary { background: var(--orange); color: var(--white); border-color: var(--orange); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--blue); color: var(--white); border-color: var(--blue); }
.btn-light { background: var(--grey-light); }
.btn-small { min-height: 34px; padding: .35rem .55rem; font-size: .86rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.alert {
  border-radius: 14px;
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-weight: 700;
}
.alert-success { background: #eaf7ef; color: var(--success); border-color: #b8e5ca; }
.alert-danger { background: #ffeceb; color: var(--danger); border-color: #ffc9c5; }
.alert-warning { background: #fff6db; color: var(--warning); border-color: #ffe1a3; }
.form-grid { display: grid; gap: 1rem; }
.form-grid h2 { margin: 1rem 0 0; }
label { display: grid; gap: .35rem; font-weight: 800; }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--grey-border);
  border-radius: 12px;
  padding: .7rem .8rem;
  font: inherit;
  background: var(--white);
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(37, 99, 235, .18); border-color: var(--blue); }
.checkbox { display: flex; flex-direction: row; align-items: center; gap: .6rem; }
.checkbox input { width: 22px; height: 22px; min-height: auto; }
.help { color: var(--grey); font-size: .95rem; }
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: .8rem; border-bottom: 1px solid var(--grey-border); vertical-align: top; }
th { background: var(--grey-light); font-size: .9rem; }
.actions-cell { min-width: 210px; }
.inline-form { display: inline; }
.footer { text-align: center; color: var(--grey); padding: 1rem; font-size: .9rem; }
code { background: var(--grey-light); padding: .15rem .35rem; border-radius: 6px; }

@media (max-width: 900px) {
  .cards-4, .cards-3, .cards-2 { grid-template-columns: 1fr 1fr; }
  .hero, .page-title { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 680px) {
  .container { width: min(100% - 1rem, 1180px); margin-top: .6rem; }
  .topbar { align-items: flex-start; }
  .menu-toggle {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: .55rem .8rem;
    border: 1px solid var(--grey-border);
    border-radius: 12px;
    background: var(--white);
    font-weight: 800;
  }
  .main-nav {
    display: none;
    position: absolute;
    right: .8rem;
    top: 68px;
    width: min(290px, calc(100vw - 1.6rem));
    flex-direction: column;
    align-items: stretch;
    background: var(--white);
    border: 1px solid var(--grey-border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: .5rem;
  }
  .main-nav.open { display: flex; }
  .main-nav a { border-radius: 12px; }
  .cards-4, .cards-3, .cards-2 { grid-template-columns: 1fr; }
  .card { border-radius: 16px; padding: 1rem; }
  .btn { width: 100%; }
  .actions-cell .btn { width: auto; margin-bottom: .25rem; }
}

/* Pack 2 - Rendez-vous et rappels */
.status.info { background: var(--blue-soft); color: var(--blue); }
.badge-association { background: #fff0e6; color: var(--orange-dark); }
.badge-personal { background: var(--blue-soft); color: var(--blue); }
.filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}
.filter-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.detail-list dl { display: grid; grid-template-columns: 140px 1fr; gap: .55rem .8rem; margin: 0; }
.detail-list dt { color: var(--grey); font-weight: 800; }
.detail-list dd { margin: 0; }
.note-box { background: var(--grey-light); border: 1px solid var(--grey-border); border-radius: 14px; padding: 1rem; }
.compact-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.compact-list li { border: 1px solid var(--grey-border); border-radius: 14px; padding: .8rem; background: #fff; }
@media (max-width: 980px) {
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .filters-grid, .form-grid-2 { grid-template-columns: 1fr; }
  .filter-actions { flex-direction: column; }
  .detail-list dl { grid-template-columns: 1fr; }
  .detail-list dt { margin-top: .5rem; }
}

/* Pack 3 - Notes, demandes, appels et aide à la prise de note */
.status.warning { background: #fff6db; color: var(--warning); }
.status.muted { background: #edf0f3; color: var(--grey); }
.status.normal { background: var(--grey-light); color: var(--grey); }
.badge-note { background: #eef2ff; color: var(--blue); }
.quick-note-panel { border-left: 6px solid var(--orange); }
.quick-actions .btn { min-width: 170px; }
.notes-filters { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.filter-checkbox { align-self: center; margin-top: 1.4rem; }
.template-preview {
  white-space: pre-wrap;
  background: var(--grey-light);
  border: 1px solid var(--grey-border);
  border-radius: 14px;
  padding: 1rem;
  font-family: inherit;
  line-height: 1.5;
  overflow-x: auto;
}
.preserve-lines { white-space: pre-wrap; }
.vertical-actions { flex-direction: column; align-items: stretch; }
.btn.disabled, .btn[aria-disabled="true"] {
  opacity: .6;
  cursor: not-allowed;
  pointer-events: none;
}
.note-status-actions { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--grey-border); }

@media (max-width: 980px) {
  .notes-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .notes-filters { grid-template-columns: 1fr; }
  .quick-actions .btn { min-width: 100%; }
  .filter-checkbox { margin-top: 0; }
}

/* Pack 4 - Tâches et tâches récurrentes */
.badge-task { background: #eef2f7; color: var(--grey); }
.badge-recurring { background: #fff0e6; color: var(--orange-dark); }
.task-panel { border-left-color: var(--blue); }
.tasks-filters { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.note-link-box { border-left: 6px solid var(--blue); }
@media (max-width: 1100px) {
  .tasks-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .tasks-filters { grid-template-columns: 1fr; }
}
