/* =====================================================================
   BP - Design system "banquier"
   Palette : bleu nuit + or + gris ardoise
   ===================================================================== */

:root {
  /* Couleurs */
  --c-bg:           #f5f7fa;
  --c-bg-card:      #ffffff;
  --c-ink:          #0a2540;
  --c-ink-soft:     #1f3a5f;
  --c-muted:        #5b6b7e;
  --c-line:         #e2e8f0;
  --c-line-strong:  #cbd5e0;
  --c-gold:         #c9a961;
  --c-gold-soft:    #f3ecd6;
  --c-positive:     #2da160;
  --c-positive-bg:  #e6f4ec;
  --c-negative:     #c5283d;
  --c-negative-bg:  #fbe7ea;
  --c-warning:      #d97706;
  --c-warning-bg:   #fef3e2;

  /* Typo */
  --f-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --f-mono: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;

  /* Espacement */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;

  /* Sidebar */
  --w-sidebar: 280px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--f-sans);
  font-size: 14px;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--c-ink-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-weight: 600;
  color: var(--c-ink);
  letter-spacing: -0.01em;
  margin: 0;
}
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-muted); }

p { margin: 0 0 12px 0; line-height: 1.55; }

/* =====================================================================
   Boutons
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-family: var(--f-sans);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: #444;
  border: 1px solid #444;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: #2d2d2d; border-color: #2d2d2d; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--c-ink);
  border-color: var(--c-ink);
}
.btn-primary:hover { background: var(--c-ink-soft); border-color: var(--c-ink-soft); }

.btn-gold {
  background: var(--c-gold);
  border-color: var(--c-gold);
  color: var(--c-ink);
}
.btn-gold:hover { background: #b8965a; border-color: #b8965a; }

.btn-ghost {
  background: transparent;
  color: var(--c-ink);
  border-color: var(--c-line-strong);
}
.btn-ghost:hover { background: var(--c-bg); }

.btn-danger {
  background: var(--c-negative);
  border-color: var(--c-negative);
}
.btn-danger:hover { background: #a01e2f; border-color: #a01e2f; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* =====================================================================
   Champs
   ===================================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.input, .textarea, .select {
  font-family: var(--f-sans);
  font-size: 14px;
  color: var(--c-ink);
  background: #fff;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--c-ink);
  box-shadow: 0 0 0 3px rgba(10, 37, 64, 0.08);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }

/* =====================================================================
   Page de connexion
   ===================================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a2540 0%, #1f3a5f 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  padding: 36px 32px;
  border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.login-brand {
  text-align: center;
  margin-bottom: 24px;
}
.login-brand .logo {
  display: inline-block;
  font-family: var(--f-sans);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-ink);
}
.login-brand .logo span { color: var(--c-gold); }
.login-brand .tagline {
  margin-top: 4px;
  font-size: 12px;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.login-error {
  background: var(--c-negative-bg);
  color: var(--c-negative);
  border: 1px solid var(--c-negative);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.login-error.visible { display: block; }

/* =====================================================================
   Layout application (sidebar + main)
   ===================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--w-sidebar) 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--c-ink);
  color: #cdd9e8;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 0 22px 18px 22px;
  border-bottom: 1px solid #1f3a5f;
}
.sidebar-brand .logo {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.sidebar-brand .logo span { color: var(--c-gold); }
.sidebar-brand .bp-current {
  margin-top: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6e8aaa;
}
.sidebar-brand .bp-name {
  font-size: 14px;
  color: #fff;
  font-weight: 500;
  margin-top: 2px;
}

.sidebar-section {
  padding: 14px 22px 6px 22px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #6e8aaa;
  font-weight: 600;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 22px;
  color: #cdd9e8;
  font-size: 13.5px;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.sidebar-nav li a:hover {
  background: #133255;
  color: #fff;
  text-decoration: none;
}
.sidebar-nav li a.active {
  background: #133255;
  color: #fff;
  border-left-color: var(--c-gold);
}
.sidebar-nav li a .num {
  display: inline-block;
  width: 22px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: #6e8aaa;
}
.sidebar-nav li a.active .num { color: var(--c-gold); }

.sidebar-footer {
  margin-top: auto;
  padding: 18px 22px;
  border-top: 1px solid #1f3a5f;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-footer a {
  color: #cdd9e8;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-footer a:hover { color: #fff; text-decoration: none; }

/* =====================================================================
   Zone principale
   ===================================================================== */
.main {
  background: var(--c-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--c-line);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title h1 { font-size: 19px; }
.topbar-title .crumb {
  font-size: 11px;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content {
  padding: 28px 32px 60px 32px;
  max-width: 1280px;
  width: 100%;
}

/* =====================================================================
   Cards
   ===================================================================== */
.card {
  background: var(--c-bg-card);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}
.card-header h2 { font-size: 16px; }
.card-header .subtitle {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 2px;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-muted);
  font-weight: 600;
}
.kpi .value {
  font-family: var(--f-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--c-ink);
  margin-top: 6px;
  letter-spacing: -0.01em;
}
.kpi .trend {
  font-size: 12px;
  margin-top: 4px;
  color: var(--c-muted);
}
.kpi .trend.positive { color: var(--c-positive); }
.kpi .trend.negative { color: var(--c-negative); }
.kpi.gold::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 4px; height: 100%;
  background: var(--c-gold);
}

/* =====================================================================
   Tableaux financiers
   ===================================================================== */
.fin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.fin-table th, .fin-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--c-line);
}
.fin-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  font-weight: 600;
  background: #fafbfc;
}
.fin-table td.num, .fin-table th.num {
  text-align: right;
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
}
.fin-table tr:nth-child(even) td { background: #fafbfc; }
.fin-table tr.total td {
  font-weight: 700;
  background: #f0f4fa !important;
  border-top: 2px solid var(--c-ink);
  border-bottom: 2px solid var(--c-ink);
}
.fin-table tr.subtotal td {
  font-weight: 600;
  background: #f5f8fc !important;
}

/* =====================================================================
   Badges et statuts
   ===================================================================== */
.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 100px;
  background: var(--c-line);
  color: var(--c-muted);
}
.badge.positive { background: var(--c-positive-bg); color: var(--c-positive); }
.badge.negative { background: var(--c-negative-bg); color: var(--c-negative); }
.badge.warning  { background: var(--c-warning-bg); color: var(--c-warning); }
.badge.gold     { background: var(--c-gold-soft); color: #8d7128; }

/* =====================================================================
   État vide / placeholder
   ===================================================================== */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--c-muted);
}
.empty .title {
  font-size: 16px;
  color: var(--c-ink);
  font-weight: 600;
  margin-bottom: 6px;
}
.empty .desc { font-size: 13px; max-width: 460px; margin: 0 auto 16px auto; line-height: 1.55; }

/* =====================================================================
   Liste des BP (page d'accueil)
   ===================================================================== */
.bp-list { display: grid; gap: 12px; }
.bp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  transition: border-color 0.1s, transform 0.05s;
}
.bp-item:hover { border-color: var(--c-ink); }
.bp-item .info .name { font-size: 15px; font-weight: 600; color: var(--c-ink); }
.bp-item .info .meta { font-size: 12px; color: var(--c-muted); margin-top: 2px; }
.bp-item .actions { display: flex; gap: 8px; }

/* =====================================================================
   Modal
   ===================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 37, 64, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-backdrop.visible { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--r-lg);
  padding: 26px 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal h2 { margin-bottom: 14px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* =====================================================================
   Toast
   ===================================================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--c-ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--c-positive); }
.toast.error { background: var(--c-negative); }

/* =====================================================================
   Responsive
   ===================================================================== */
/* =====================================================================
   Topbar - centre (progression + indicateur sauvegarde)
   ===================================================================== */
.topbar-center {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  justify-content: center;
}
.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-bar {
  width: 120px;
  height: 6px;
  background: var(--c-line);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--c-positive);
  border-radius: 3px;
  transition: width 0.3s;
  width: 0;
}
.progress-text {
  font-size: 11px;
  color: var(--c-muted);
  font-weight: 500;
  white-space: nowrap;
}

.save-indicator {
  font-size: 12px;
  white-space: nowrap;
  min-height: 18px;
}
.save-indicator.saved { color: var(--c-positive); }
.save-indicator.dirty { color: var(--c-warning); }
.save-indicator.saving { color: var(--c-muted); font-style: italic; }
.save-indicator.error { color: var(--c-negative); }

/* =====================================================================
   Sidebar - badges de statut
   ===================================================================== */
.sidebar-nav li a .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-left: auto;
  flex-shrink: 0;
}
.status-dot.en_cours { background: var(--c-warning); }
.status-dot.valide { background: var(--c-positive); }

/* =====================================================================
   Panneau questions guides
   ===================================================================== */
.guide-panel {
  background: var(--c-gold-soft);
  border: 1px solid #e8dbb8;
  border-radius: var(--r-lg);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.guide-header h4 {
  margin: 0;
  font-size: 12px;
  color: #8d7128;
}
.guide-toggle {
  font-size: 12px;
  color: #8d7128;
  cursor: pointer;
}
.guide-toggle:hover { text-decoration: underline; }
.guide-list {
  margin: 10px 0 0 0;
  padding-left: 18px;
  list-style-type: disc;
}
.guide-list li {
  font-size: 13px;
  color: #6b5a2e;
  line-height: 1.7;
}
.guide-panel.collapsed .guide-list { display: none; }

/* =====================================================================
   Editeur de section (Quill)
   ===================================================================== */
.section-editor {}
.section-header { margin-bottom: 16px; }
.section-header .card-header { margin-bottom: 0; }

.editor-card {
  padding: 0 !important;
  overflow: hidden;
}
.editor-card .ql-toolbar.ql-snow {
  border: none !important;
  border-bottom: 1px solid var(--c-line) !important;
  background: #fafbfc;
  padding: 10px 14px !important;
}
.editor-card .ql-container.ql-snow {
  border: none !important;
  font-family: var(--f-sans);
  font-size: 14px;
}
.editor-card .ql-editor {
  min-height: 350px;
  padding: 20px 24px;
  line-height: 1.7;
  color: var(--c-ink);
}
.editor-card .ql-editor h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 20px 0 8px 0;
}
.editor-card .ql-editor h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 0 6px 0;
}
.editor-card .ql-editor p {
  margin: 0 0 8px 0;
}
.editor-card .ql-editor ul,
.editor-card .ql-editor ol {
  padding-left: 24px;
  margin: 0 0 8px 0;
}
.editor-card .ql-editor.ql-blank::before {
  color: var(--c-muted);
  font-style: italic;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-top: 4px;
}
.editor-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--c-muted);
}
.editor-stats span {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
}

/* =====================================================================
   Configuration juridique (Lot 2a)
   ===================================================================== */
.config-page {}

.config-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 24px;
}

.config-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--c-ink);
  padding: 9px 0;
  min-height: 38px;
  display: flex;
  align-items: center;
}

.config-is-info {
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--c-gold-soft);
  border: 1px solid #e8dbb8;
  border-radius: var(--r-md);
  font-size: 13px;
}
.config-is-label {
  font-weight: 600;
  color: #8d7128;
  margin-bottom: 4px;
}
.config-is-rates {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #6b5a2e;
}

.config-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  font-size: 13px;
}
.config-summary-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.config-summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  font-weight: 600;
}

/* =====================================================================
   Investissements (Lot 2b)
   ===================================================================== */
.invest-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 24px;
}

/* =====================================================================
   Dashboard - lignes cliquables
   ===================================================================== */
.section-row:hover td {
  background: var(--c-bg) !important;
}

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .topbar { padding: 14px 20px; flex-wrap: wrap; }
  .topbar-center { order: 3; width: 100%; justify-content: flex-start; margin-top: 8px; }
  .content { padding: 20px; }
  .editor-card .ql-editor { min-height: 250px; }
}
