:root {
  --blue:        #1F4E91;
  --blue-dark:   #163D73;
  --blue-light:  #EBF0F8;
  --gray:        #58595B;
  --gray-light:  #8A8B8D;
  --bg:          #F5F5F5;
  --white:       #FFFFFF;
  --border:      #D8D9DA;
  --r:           6px;
  --shadow:      0 1px 3px rgba(0,0,0,.10);
  --t:           .15s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--gray);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Navigation ─────────────────────────────────────────────────────────────── */
.nav {
  background: var(--blue);
  height: 54px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
  gap: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-brand {
  font-weight: 700;
  font-size: .9375rem;
  letter-spacing: .04em;
  color: #fff;
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}
.nav-links { display: flex; overflow-x: auto; }
.nav-link {
  color: rgba(255,255,255,.78);
  text-decoration: none;
  padding: 0 .8rem;
  height: 54px;
  display: flex;
  align-items: center;
  font-size: .8125rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--t), color var(--t);
  border-bottom: 2px solid transparent;
}
.nav-link:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-link.active { color: #fff; border-bottom-color: #fff; }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.main { max-width: 700px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* ── Card ────────────────────────────────────────────────────────────────────── */
.card { background: var(--white); border-radius: var(--r); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; }
.card-title { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--blue); margin-bottom: 1rem; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: .875rem; }
.form-label { display: block; font-size: .8125rem; font-weight: 600; margin-bottom: .3rem; }
.form-control {
  display: block; width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: .9375rem;
  color: var(--gray);
  background: var(--white);
  transition: border-color var(--t), box-shadow var(--t);
  -webkit-appearance: none; appearance: none;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
.form-control:disabled { background: var(--bg); color: var(--gray-light); cursor: not-allowed; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7'%3E%3Cpath d='M1 1l4.5 4.5L10 1' stroke='%2358595B' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}
textarea.form-control { resize: vertical; min-height: 72px; }

/* ── Duration ────────────────────────────────────────────────────────────────── */
.dur-btns { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.btn-dur {
  padding: .4rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--white);
  color: var(--gray);
  font-size: .875rem;
  cursor: pointer;
  transition: all var(--t);
  font-family: inherit;
  min-height: 36px;
}
.btn-dur:hover  { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-dur.active { background: var(--blue); border-color: var(--blue); color: #fff; }

.dur-custom { display: flex; align-items: center; gap: .5rem; margin-top: .375rem; }
.dur-custom input { width: 90px; }
.dur-custom span  { font-size: .8125rem; color: var(--gray-light); }

/* ── Comment + mic ───────────────────────────────────────────────────────────── */
.comment-wrap { display: flex; gap: .5rem; align-items: flex-start; }
.comment-wrap textarea { flex: 1; }
.btn-mic {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--gray-light);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--t);
  padding: 0;
}
.btn-mic:hover { border-color: var(--blue); color: var(--blue); }
.btn-mic.on    { background: #d32f2f; border-color: #d32f2f; color: #fff; animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.65} }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  padding: .5625rem 1.125rem;
  border-radius: var(--r);
  font-size: .9375rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: all var(--t);
  text-decoration: none;
  font-family: inherit;
  line-height: 1;
}
.btn-primary  { background: var(--blue); color: #fff; }
.btn-primary:hover  { background: var(--blue-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-ghost  { background: transparent; color: var(--blue); border: 1px solid var(--blue); }
.btn-ghost:hover  { background: var(--blue-light); }
.btn-muted  { background: transparent; color: var(--gray-light); border: 1px solid var(--border); }
.btn-muted:hover  { border-color: var(--gray); color: var(--gray); }
.btn-danger { background: transparent; color: #c62828; border: 1px solid #c62828; }
.btn-danger:hover { background: #ffebee; }
.btn-sm     { padding: .3rem .625rem; font-size: .8125rem; }
.btn-full   { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Toast ───────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%;
  transform: translateX(-50%) translateY(80px);
  padding: .625rem 1.375rem;
  border-radius: var(--r);
  font-size: .875rem; font-weight: 500;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  transition: transform .28s ease;
  z-index: 200; pointer-events: none; white-space: nowrap;
  background: var(--gray); color: #fff;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.ok   { background: #2e7d32; }
.toast.err  { background: #c62828; }

/* ── Historique ──────────────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: .875rem; }
.filters .form-control { flex: 1; min-width: 130px; }

.total-bar {
  background: var(--blue); color: #fff;
  border-radius: var(--r); padding: .625rem 1rem;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: .875rem; font-weight: 600; font-size: .9375rem;
}
.total-bar .count { font-weight: 400; font-size: .8125rem; opacity: .85; }

.itv {
  background: var(--white); border-radius: var(--r);
  padding: .75rem 1rem; margin-bottom: .4375rem;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--blue);
}
.itv-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .2rem; }
.itv-client { font-weight: 700; font-size: .9375rem; }
.itv-dur    { font-weight: 700; color: var(--blue); font-size: .875rem; white-space: nowrap; }
.itv-meta   { font-size: .8125rem; color: var(--gray-light); }
.itv-comment { font-size: .8125rem; color: var(--gray); font-style: italic; margin-top: .3rem; }

/* ── Admin lists ─────────────────────────────────────────────────────────────── */
.a-list { list-style: none; }
.a-item {
  display: flex; align-items: center; gap: .625rem;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}
.a-item:last-child { border-bottom: none; }
.a-item-name { flex: 1; font-size: .9375rem; }
.a-item-name.off { color: var(--gray-light); text-decoration: line-through; }

.badge {
  font-size: .6875rem; font-weight: 700;
  padding: .1rem .45rem; border-radius: 999px;
  background: var(--blue-light); color: var(--blue);
}
.badge.off { background: var(--bg); color: var(--gray-light); }

.add-row {
  display: flex; gap: .5rem; margin-top: .875rem; padding-top: .875rem;
  border-top: 1px solid var(--border);
}
.add-row .form-control { flex: 1; }

/* ── Inline edit ─────────────────────────────────────────────────────────────── */
.edit-row { display: flex; gap: .375rem; align-items: center; flex: 1; }
.edit-row input { flex: 1; }

/* ── Référentiels accordion ──────────────────────────────────────────────────── */
.ref-famille {
  background: var(--white); border-radius: var(--r);
  box-shadow: var(--shadow); margin-bottom: .625rem; overflow: hidden;
}
.ref-famille-hdr {
  display: flex; align-items: center; gap: .625rem;
  padding: .75rem 1rem; cursor: pointer;
  border-bottom: 2px solid var(--blue-light);
  transition: background var(--t);
}
.ref-famille-hdr:hover { background: var(--blue-light); }
.ref-famille-hdr .chevron { font-size: .75rem; transition: transform var(--t); flex-shrink: 0; }
.ref-famille-hdr.open .chevron { transform: rotate(90deg); }
.ref-famille-nom { flex: 1; font-weight: 700; color: var(--blue); font-size: .9375rem; }
.ref-famille-nom.off { color: var(--gray-light); text-decoration: line-through; }

.ref-famille-body { display: none; padding: .75rem 1rem; }
.ref-famille-hdr.open ~ .ref-famille-body { display: block; }

.ref-types { list-style: none; }
.ref-type-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .375rem 0; border-bottom: 1px solid var(--bg);
}
.ref-type-item:last-child { border-bottom: none; }
.ref-type-name { flex: 1; font-size: .9rem; }
.ref-type-name.off { color: var(--gray-light); text-decoration: line-through; }

.ref-add-type {
  display: flex; gap: .4rem; margin-top: .75rem; padding-top: .75rem;
  border-top: 1px solid var(--border);
}
.ref-add-type .form-control { flex: 1; }

.ref-new-famille {
  display: flex; gap: .5rem; margin-top: 1rem;
}
.ref-new-famille .form-control { flex: 1; }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--gray-light); }
.empty svg { opacity: .35; margin-bottom: .75rem; }

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal {
  background: var(--white); border-radius: var(--r);
  padding: 1.375rem; width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.modal-title { font-weight: 700; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* ── Déconnexion ─────────────────────────────────────────────────────────────── */
.nav-logout {
  color: rgba(255,255,255,.55);
  text-decoration: none;
  padding: 0 .6rem;
  height: 54px;
  display: flex; align-items: center;
  font-size: .8125rem;
  white-space: nowrap;
  border-left: 1px solid rgba(255,255,255,.15);
  margin-left: .25rem;
  transition: color var(--t);
  gap: .3rem;
}
.nav-logout:hover { color: rgba(255,255,255,.9); }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .main { padding: .875rem .75rem 3rem; }
  .card { padding: 1rem; }
  .nav-link { padding: 0 .6rem; }
  .filters .form-control { min-width: 100%; }
}
