/* ============================================================
   Gardien — Mandat de protection extrajudiciaire
   Design system : direction éditoriale "confiance patrimoniale"
   Papier chaud, encre profonde, vert patrimonial, sérif Fraunces.
   ============================================================ */

:root {
  /* Palette */
  --paper: #F6F3EC;
  --paper-2: #EFEBE1;
  --surface: #FFFFFF;
  --ink: #1C2430;
  --ink-soft: #3A4352;
  --muted: #6E6B63;
  --line: #E4DFD3;
  --accent: #2F6B4F;
  --accent-ink: #1F4A37;
  --accent-soft: #E4EFE8;
  --amber: #B98A2F;
  --amber-soft: #F5EBD8;
  --danger: #B0483E;
  --danger-soft: #F6E5E3;
  --info: #3E7C8C;
  --info-soft: #E3EFF2;
  --shadow-sm: 0 1px 2px rgba(28, 36, 48, .06);
  --shadow-md: 0 6px 24px -8px rgba(28, 36, 48, .14);
  --shadow-lg: 0 18px 50px -12px rgba(28, 36, 48, .22);

  /* Typographie */
  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;

  /* Rayons & espacements */
  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 18px;
  --sidebar-w: 248px;
  --header-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(47, 107, 79, .07), transparent 60%),
    radial-gradient(900px 400px at -10% 30%, rgba(185, 138, 47, .05), transparent 55%),
    var(--paper);
  min-height: 100vh;
}

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  color: #EDEAE2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 14px;
  gap: 4px;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 18px;
  color: #F4F1E9;
  text-decoration: none;
}
.brand-mark {
  width: 34px; height: 34px; flex-shrink: 0;
  background: linear-gradient(140deg, var(--accent), #3E8A63);
  border-radius: 10px;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), var(--shadow-md);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-name {
  font-family: var(--font-display);
  font-size: 19px; font-weight: 600; letter-spacing: .2px;
}
.brand-sub { font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: #A9B3A4; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .16em;
  color: #7E8A7E; padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  color: #C9CDBF;
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #F4F1E9; }
.nav-item.active { background: rgba(47,107,79,.35); color: #FFFFFF; }
.nav-item.active::before {
  content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: #6FBF94;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.nav-item .count {
  margin-left: auto; background: rgba(255,255,255,.14);
  border-radius: 99px; font-size: 11px; padding: 1px 8px;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 12px;
  background: rgba(255,255,255,.05);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.user-chip .u-name { font-size: 13px; font-weight: 600; color: #F4F1E9; }
.user-chip .u-role { font-size: 11px; color: #A9B3A4; }
.user-chip a { color: #A9B3A4; text-decoration: none; font-size: 12px; }
.user-chip a:hover { color: #fff; }

.content {
  flex: 1;
  min-width: 0;
  padding: 28px 34px 60px;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
}

/* Barre mobile */
.mobile-bar {
  display: none;
  position: sticky; top: 0; z-index: 40;
  background: var(--ink); color: #EDEAE2;
  padding: 12px 16px;
  align-items: center; gap: 12px;
}
.mobile-bar .brand-name { font-family: var(--font-display); font-size: 18px; }
.mobile-bar button {
  background: rgba(255,255,255,.1); border: 0; color: #fff;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center; cursor: pointer;
}
.mobile-bar svg { width: 20px; height: 20px; }

@media (max-width: 920px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-bar { display: flex; }
  .content { padding: 20px 16px 60px; }
  .scrim {
    position: fixed; inset: 0; background: rgba(28,36,48,.45);
    z-index: 45; opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .scrim.open { opacity: 1; pointer-events: auto; }
}

/* ---------- Typographie ---------- */
.kicker {
  font-size: 11px; text-transform: uppercase; letter-spacing: .18em;
  color: var(--accent); font-weight: 700; margin: 0 0 6px;
}
.page-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.4vw, 34px);
  font-weight: 600; line-height: 1.15; margin: 0 0 4px;
  letter-spacing: -.01em;
}
.page-desc { color: var(--muted); margin: 0 0 24px; font-size: 14.5px; max-width: 640px; }
h2.section { font-family: var(--font-display); font-size: 19px; font-weight: 600; margin: 30px 0 12px; }

/* ---------- Cartes & indicateurs ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.card-title { font-weight: 600; font-size: 14px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-title svg { width: 16px; height: 16px; color: var(--accent); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
  animation: rise .5s ease both;
}
.kpi:nth-child(2) { animation-delay: .06s; }
.kpi:nth-child(3) { animation-delay: .12s; }
.kpi:nth-child(4) { animation-delay: .18s; }
.kpi::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--accent); border-radius: 3px 3px 0 0;
}
.kpi.amber::after { background: var(--amber); }
.kpi.muted::after { background: var(--muted); }
.kpi.danger::after { background: var(--danger); }
.kpi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.kpi-value {
  font-family: var(--font-display);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 600; margin-top: 6px; letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 15px; color: var(--muted); font-weight: 500; }
.kpi-note { font-size: 12px; color: var(--muted); margin-top: 4px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px;
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge.amber { background: var(--amber-soft); color: #7A5A17; }
.badge.muted { background: #ECE9E0; color: var(--muted); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: transform .08s, box-shadow .15s, background .15s;
  line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: #C9C2B2; background: #FBFAF6; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #94392F; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.sm svg { width: 14px; height: 14px; }
.btn svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Tableaux ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; padding: 11px 14px;
  border-bottom: 1px solid var(--line); background: var(--paper-2);
  white-space: nowrap;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid #EFEBE1; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: #FBFAF5; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
table.data .pos { color: var(--accent); }
table.data .neg { color: var(--danger); }
table.data .muted-cell { color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  width: 30px; height: 30px; cursor: pointer; color: var(--muted);
  display: grid; place-items: center; transition: all .12s;
}
.row-actions .icon-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.row-actions .icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.row-actions svg { width: 15px; height: 15px; }

/* ---------- Formulaires ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,107,79,.14); }
textarea.input { resize: vertical; min-height: 70px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- Alertes ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-radius: var(--r-md);
  font-size: 14px; margin-bottom: 14px;
  border: 1px solid transparent;
  animation: rise .35s ease both;
}
.alert.success { background: var(--accent-soft); border-color: #C7DCCD; color: var(--accent-ink); }
.alert.error { background: var(--danger-soft); border-color: #EDCFCB; color: #7E2E26; }
.alert.info { background: var(--info-soft); border-color: #C6DDE3; color: #235461; }
.alert.warning { background: var(--amber-soft); border-color: #E8D9B5; color: #6B4E14; }
.alert .close { margin-left: auto; background: none; border: 0; cursor: pointer; color: inherit; opacity: .6; font-size: 16px; }
.alert .close:hover { opacity: 1; }

/* ---------- Boîtes modales ---------- */
dialog.modal {
  border: 0; border-radius: var(--r-lg); padding: 0;
  max-width: 520px; width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
}
dialog.modal::backdrop { background: rgba(28,36,48,.5); backdrop-filter: blur(2px); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0;
}
.modal-head h3 { font-family: var(--font-display); font-size: 19px; margin: 0; }
.modal-head .x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 14px 22px 22px; }
.modal-body p { margin-top: 0; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); font-size: 13px; background: var(--surface);
}
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* ---------- Utilitaires ---------- */
.flex { display: flex; align-items: center; gap: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.empty {
  text-align: center; padding: 40px 20px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--r-md); background: rgba(255,255,255,.5);
}
.empty svg { width: 34px; height: 34px; opacity: .4; margin-bottom: 8px; }
.money-pos { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.money-neg { color: var(--danger); font-weight: 700; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  background: var(--paper-2); color: var(--ink-soft); font-size: 12px; font-weight: 500;
}
details.faq { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); padding: 12px 16px; margin-bottom: 10px; }
details.faq summary { cursor: pointer; font-weight: 600; }

/* ---------- Graphique flux (SVG) ---------- */
.flow-chart { width: 100%; height: auto; }
.flow-chart text { font-family: var(--font-body); fill: var(--muted); font-size: 10.5px; }
.flow-legend { display: flex; gap: 18px; justify-content: flex-end; font-size: 12px; color: var(--muted); margin-top: 8px; }
.flow-legend span { display: inline-flex; align-items: center; gap: 6px; }
.flow-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Impression ---------- */
@media print {
  .sidebar, .mobile-bar, .no-print { display: none !important; }
  .content { max-width: 100%; padding: 0; }
  body { background: #fff; }
}
