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

:root {
  --navy:   #0D2137;
  --blue:   #1A4A7A;
  --azure:  #2979C2;
  --sky:    #4BA3E3;
  --gold:   #C8A84B;
  --gold-lt:#F0DFA0;
  --cream:  #F5F0E8;
  --light:  #EEF4FB;
  --white:  #FFFFFF;
  --text:   #1A2D42;
  --muted:  #5C7A99;
  --border: #C5D8ED;
  --ok:     #1E7F4E;
  --err:    #B91C1C;
  --warn:   #92680A;
  --radius: 10px;
  --shadow: 0 4px 24px rgba(13,33,55,.12);
}

html { font-family: 'DM Sans', sans-serif; font-size: 14px; }
body { background: var(--cream); color: var(--text); min-height: 100vh; }

/* ── HEADER ── */
header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 60%, var(--azure) 100%);
  padding: 0 40px;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
  box-shadow: 0 2px 12px rgba(13,33,55,.3);
  position: sticky; top: 0; z-index: 100;
}
.header-brand {
  display: flex; align-items: center; gap: 14px;
}
.header-logo {
  width: 36px; height: 36px;
  background: var(--gold);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'DM Serif Display', serif;
  font-size: 18px; color: var(--navy); font-weight: 700;
}
.header-title {
  font-family: 'DM Serif Display', serif;
  font-size: 18px; color: var(--white);
  line-height: 1.2;
}
.header-subtitle { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 1px; }
.header-badge {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.2);
  color: rgba(255,255,255,.8);
  font-size: 11px; padding: 4px 10px; border-radius: 20px;
}

/* ── LAYOUT ── */
.app { display: flex; min-height: calc(100vh - 64px); }

/* ── SIDEBAR ── */
aside {
  width: 320px; flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  display: flex; flex-direction: column; gap: 24px;
  overflow-y: auto;
}

.section-label {
  font-size: 10px; font-weight: 600; letter-spacing: .1em;
  color: var(--muted); text-transform: uppercase;
  margin-bottom: 10px;
}

/* Login panel */
.login-panel {
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.login-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; margin-top: 10px;
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ccc; flex-shrink: 0;
  transition: background .3s;
}
.dot.ok  { background: var(--ok); box-shadow: 0 0 0 3px rgba(30,127,78,.2); }
.dot.err { background: var(--err); }

/* Form elements */
label { font-size: 12px; font-weight: 500; color: var(--muted); display: block; margin-bottom: 4px; }
input, select {
  width: 100%; padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  font-family: inherit; font-size: 13px; color: var(--text);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--azure);
  box-shadow: 0 0 0 3px rgba(41,121,194,.15);
}
input[type=password] { letter-spacing: 2px; }

.field { margin-bottom: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: all .2s;
  width: 100%;
}
.btn-primary {
  background: linear-gradient(135deg, var(--azure), var(--blue));
  color: var(--white);
  box-shadow: 0 3px 10px rgba(41,121,194,.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(41,121,194,.4); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), #A8882A);
  color: var(--navy);
  box-shadow: 0 3px 10px rgba(200,168,75,.3);
}
.btn-gold:hover { transform: translateY(-1px); }
.btn-gold:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--azure); color: var(--azure); }

/* Divider */
hr { border: none; border-top: 1px solid var(--border); }

/* ── MAIN ── */
main {
  flex: 1; padding: 32px 40px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 28px;
}

/* Search bar */
.search-bar {
  display: flex; gap: 10px;
  position: relative;
}
.search-bar input { flex: 1; font-size: 14px; }
.search-bar .btn { width: auto; padding: 10px 20px; }

/* Search Dropdown */
.search-dropdown {
  display: none;
  position: absolute; top: 100%; left: 0; right: 80px;
  background: var(--white);
  border: 1.5px solid var(--azure);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(41,121,194,.2);
}
.search-dropdown.active {
  display: block;
}
.dropdown-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid #F0F4F9;
  transition: background .1s;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
}
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #F9FCFE; }
.dropdown-item-name {
  flex: 1; font-weight: 500; font-size: 13px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dropdown-item-meta {
  font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  max-width: 150px;
}
.dropdown-item-siren {
  font-family: monospace; font-size: 11px;
  background: var(--light); padding: 2px 6px;
  border-radius: 4px; color: var(--azure); flex-shrink: 0;
}
.dropdown-loading {
  padding: 16px 14px;
  text-align: center; color: var(--muted);
  font-size: 12px; display: flex; gap: 8px;
  align-items: center; justify-content: center;
}
.dropdown-empty {
  padding: 16px 14px;
  text-align: center; color: var(--muted);
  font-size: 12px;
}

/* Results list */
.search-results {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.result-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
  display: flex; justify-content: space-between; align-items: center;
}
.result-item:last-child { border-bottom: none; }
.result-item:hover { background: var(--light); }
.result-name { font-weight: 600; font-size: 14px; }
.result-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.result-siren {
  font-family: monospace; font-size: 12px;
  background: var(--light); padding: 3px 8px;
  border-radius: 5px; color: var(--azure);
}

/* Bilan list */
.bilans-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.bilan-card {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
  overflow: hidden;
}
.bilan-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--azure), var(--sky));
  opacity: 0;
  transition: opacity .2s;
}
.bilan-card:hover { border-color: var(--azure); box-shadow: var(--shadow); transform: translateY(-2px); }
.bilan-card:hover::before { opacity: 1; }
.bilan-card.selected { border-color: var(--azure); box-shadow: 0 0 0 3px rgba(41,121,194,.15); }
.bilan-card.selected::before { opacity: 1; }

.bilan-year {
  font-family: 'DM Serif Display', serif;
  font-size: 28px; color: var(--navy);
}
.bilan-date { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bilan-type {
  display: inline-block; margin-top: 8px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.type-C { background: #DBEAFE; color: #1E40AF; }
.type-S { background: #D1FAE5; color: #065F46; }
.type-K { background: #EDE9FE; color: #5B21B6; }
.type-B { background: #FEF3C7; color: #92400E; }
.bilan-conf {
  position: absolute; top: 10px; right: 10px;
  font-size: 10px; padding: 2px 7px;
  border-radius: 10px; font-weight: 600;
}
.conf-public  { background: #D1FAE5; color: #065F46; }
.conf-private { background: #FEE2E2; color: #991B1B; }

/* Page viewer */
.viewer-panel {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.viewer-header {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  padding: 16px 22px;
  display: flex; justify-content: space-between; align-items: center;
}
.viewer-title {
  font-family: 'DM Serif Display', serif;
  font-size: 18px; color: var(--white);
}
.viewer-subtitle { font-size: 12px; color: rgba(255,255,255,.6); margin-top: 2px; }

.viewer-tabs {
  display: flex; overflow-x: auto;
  border-bottom: 2px solid var(--border);
  background: var(--light);
  padding: 0 16px;
  gap: 4px;
  scrollbar-width: thin;
}
.tab {
  padding: 10px 16px; cursor: pointer;
  font-size: 12px; font-weight: 600;
  color: var(--muted); white-space: nowrap;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
}
.tab:hover { color: var(--azure); }
.tab.active { color: var(--azure); border-bottom-color: var(--azure); }

/* Table */
.table-wrap { overflow-x: auto; max-height: 480px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0;
  background: var(--navy); color: var(--white);
  padding: 10px 14px; font-size: 11px; font-weight: 600;
  text-align: right; white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,.1);
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
thead th:first-child { width: 60px; }
thead th:nth-child(2) { width: 340px; }

tbody tr { transition: background .1s; }
tbody tr:nth-child(even) { background: var(--light); }
tbody tr:hover { background: #D6E8F8; }
tbody tr.total-row {
  background: #FFF8E1;
  font-weight: 700;
  border-top: 1.5px solid var(--gold-lt);
  border-bottom: 1.5px solid var(--gold-lt);
}
tbody tr.total-row:hover { background: #FFF0B3; }

td {
  padding: 9px 14px; font-size: 12px;
  border-bottom: 1px solid #EDF2F7;
}
td:first-child {
  font-family: monospace; font-size: 11px;
  color: var(--azure); font-weight: 600;
}
td.num {
  text-align: right; font-variant-numeric: tabular-nums;
  font-family: 'DM Sans', sans-serif;
  color: var(--text);
}
td.num.neg { color: var(--err); }
td.num.empty { color: #CCC; }

/* Toast */
.toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  padding: 12px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  animation: slideIn .3s ease;
  max-width: 340px;
}
.toast.ok  { background: #D1FAE5; color: #065F46; border-left: 4px solid var(--ok); }
.toast.err { background: #FEE2E2; color: #991B1B; border-left: 4px solid var(--err); }
.toast.info { background: var(--light); color: var(--blue); border-left: 4px solid var(--azure); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-title { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--navy); margin-bottom: 8px; }

/* Info box */
.info-box {
  background: var(--light);
  border: 1px solid var(--border);
  border-left: 4px solid var(--azure);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12px; color: var(--blue);
  line-height: 1.6;
}

/* Responsive */
@media (max-width: 900px) {
  .app { flex-direction: column; }
  aside { width: 100%; }
  main { padding: 20px; }
}

/* ── BOUTON AIDE (header) ── */
.btn-help {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 15px; border-radius: 20px;
  font-family: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
  background: rgba(255,255,255,.15);
  border: 1.5px solid rgba(255,255,255,.35);
  color: var(--white);
  transition: all .2s;
  letter-spacing: .02em;
}
.btn-help:hover {
  background: rgba(255,255,255,.28);
  border-color: rgba(255,255,255,.6);
  transform: translateY(-1px);
}

/* ── MODALE AIDE ── */
.help-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(13,33,55,.55);
  backdrop-filter: blur(3px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.help-overlay.open { display: flex; }

.help-modal {
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(13,33,55,.35);
  width: 100%; max-width: 680px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  animation: modalIn .25s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn {
  from { transform: scale(.92); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.help-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--navy), var(--blue));
  border-radius: 14px 14px 0 0;
}
.help-modal-title {
  font-family: 'DM Serif Display', serif;
  font-size: 17px; color: var(--white);
  display: flex; align-items: center; gap: 10px;
}
.help-close {
  width: 30px; height: 30px;
  border-radius: 50%; border: none;
  background: rgba(255,255,255,.18);
  color: var(--white); font-size: 17px;
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background .2s;
  line-height: 1;
}
.help-close:hover { background: rgba(255,255,255,.32); }

.help-modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
  line-height: 1.75;
  font-size: 13.5px;
  color: var(--text);
  white-space: pre-wrap;
  font-family: 'DM Sans', sans-serif;
}
.help-modal-body.loading {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-style: italic; gap: 10px;
}
.help-modal-body.error {
  color: var(--err);
  background: #FEE2E2;
  border-radius: 8px;
  margin: 16px;
  padding: 16px;
}
.help-modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}
.btn-help-close {
  padding: 8px 22px; border-radius: 8px;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1.5px solid var(--border);
  background: var(--white); color: var(--text);
  transition: all .2s;
}
.btn-help-close:hover { border-color: var(--azure); color: var(--azure); }

/* Graphique Plotly */
.chart-container {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 20px;
  box-shadow: var(--shadow);
  width:100%
}

.flex-c {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: auto;
}
.chart-title {
  font-family: 'DM Serif Display', serif;
  font-size: larger; color: var(--navy);
  margin-bottom: 16px; font-weight: 600;
}
#bilanChart {
  flex-grow: 1;
  width: 50% !important;
  height: 400px !important;
}

#ratio-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  font-size: larger;
  height: 400px !important;
  overflow-y: auto;
  overflow-x: auto;
}

.select-option {
  display: flex;
  flex-direction: row;
  width: 100%;
  font-size: larger;

}

.box {
    width: 16%;
    font-size: large;
  }

.select-head {
  display: flex;
  flex-direction: row;
  width: 100%;
  font-size: larger;

}

