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

:root {
  --bg:          #F8FAFC;
  --sidebar:     #FFFFFF;
  --card:        #FFFFFF;
  --border:      #E2E8F0;
  --text:        #0F172A;
  --text-2:      #475569;
  --text-3:      #94A3B8;
  --accent:      #6366F1;
  --accent-h:    #4F46E5;
  --accent-light:#EEF2FF;
  --green:       #10B981;
  --green-light: #ECFDF5;
  --red:         #EF4444;
  --red-light:   #FEF2F2;
  --radius:      12px;
  --radius-s:    6px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
#app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 232px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.5px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
}

.nav-list {
  list-style: none;
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .12s, color .12s;
  margin-bottom: 1px;
  user-select: none;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item.active .nav-icon { stroke: var(--accent); }

.nav-icon { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

#refresh-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  margin-bottom: 7px;
}

#refresh-btn:hover { background: var(--border); }
#refresh-btn:disabled { opacity: .55; cursor: not-allowed; }

#last-update {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  min-height: 14px;
}

/* ── Main ── */
.main { margin-left: 232px; flex: 1; }
.content { padding: 28px 32px; max-width: 1200px; }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Page ── */
.page { display: flex; flex-direction: column; gap: 14px; }

/* ── Overview header ── */
.overview-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 24px 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.total-label { font-size: 12px; color: var(--text-3); font-weight: 500; margin-bottom: 4px; }

.total-amount {
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.03em;
  line-height: 1;
  margin-bottom: 8px;
}

.total-change {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 500;
}
.total-change.pos { color: var(--green); }
.total-change.neg { color: var(--red); }
.total-change-period { color: var(--text-3); font-weight: 400; }

.overview-meta { display: flex; align-items: center; gap: 20px; }
.meta-item { text-align: right; }
.meta-label { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.meta-value { font-size: 15px; font-weight: 600; }
.meta-sep { width: 1px; height: 28px; background: var(--border); }

/* ── Charts row ── */
.charts-row {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 14px;
}

.allocation-card { padding: 22px; }
.evolution-card  { padding: 22px; }

.card-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 16px;
}

.allocation-inner {
  display: flex;
  gap: 18px;
  align-items: flex-start;
}

.donut-wrap { width: 130px; height: 130px; flex-shrink: 0; }

.alloc-legend { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.legend-row {
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; padding: 3px 5px;
  border-radius: 6px; transition: background .12s;
}
.legend-row:hover { background: var(--bg); }

.legend-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.legend-name { flex: 1; font-size: 12.5px; color: var(--text-2); }
.legend-val { font-size: 12.5px; font-weight: 600; }
.legend-pct { font-size: 11px; color: var(--text-3); width: 38px; text-align: right; }

.evo-canvas-wrap { position: relative; height: 180px; }
.evo-canvas-wrap canvas { position: absolute; inset: 0; }

/* ── Category cards ── */
.cats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 10px;
}

.cat-card {
  padding: 16px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.cat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.cat-dot { width: 9px; height: 9px; border-radius: 50%; margin-bottom: 10px; }
.cat-name { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.cat-val  { font-size: 17px; font-weight: 700; margin-bottom: 1px; }
.cat-pct  { font-size: 11px; color: var(--text-3); }

/* ── Section hero ── */
.section-hero {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.section-hero h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.hero-stats { display: flex; flex-wrap: wrap; gap: 28px; }

.stat-l { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
.stat-v { font-size: 1.05rem; font-weight: 600; }
.stat.highlight .stat-v { font-size: 1.2rem; }

.pct { font-size: .8em; margin-left: 4px; font-weight: 500; opacity: .85; }

/* ── Colors ── */
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ── Account card ── */
.account-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 8px;
}

.account-name { font-size: 14px; font-weight: 600; margin-right: 6px; }
.account-total { font-size: 16px; font-weight: 700; text-align: right; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: .02em;
}
.badge-pea    { background: #EEF2FF; color: #6366F1; }
.badge-peps   { background: #F0FDF4; color: #16A34A; }
.badge-cto    { background: #FFF7ED; color: #EA580C; }
.badge-per    { background: #EFF6FF; color: #2563EB; }
.badge-livret { background: #F0FDF4; color: #16A34A; }
.badge-cash   { background: #F0FDFA; color: #0F766E; }
.badge-immo   { background: #FFF7ED; color: #C2410C; }
.badge-divers { background: #F5F3FF; color: #7C3AED; }

.badge-broker {
  font-size: 12px; color: var(--text-3); margin-left: 3px;
}

.owner-chip {
  display: inline-flex; align-items: center;
  padding: 2px 6px; border-radius: 20px;
  font-size: 10.5px; font-weight: 500;
  margin-left: 4px;
}

.rate-badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 20px;
  font-size: 10.5px; font-weight: 600;
  background: #F0FDF4; color: #16A34A;
  margin-left: 4px;
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }

.ptable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ptable th {
  padding: 9px 12px;
  font-size: 10.5px; font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg);
}

.ptable td {
  padding: 9px 12px;
  border-bottom: 1px solid #F8FAFC;
  vertical-align: middle;
  white-space: nowrap;
}

.ptable tbody tr:hover td { background: #FAFBFC; }
.ptable tbody tr:last-child td { border-bottom: none; }

.ptable tfoot td {
  padding: 9px 12px;
  border-top: 1px solid var(--border);
  border-bottom: none;
  background: #F8FAFC;
}

.r { text-align: right; }

.td-name   { font-weight: 500; white-space: normal; min-width: 160px; }
.td-ticker { font-size: 11px; color: var(--text-3); font-family: 'SF Mono', monospace; }

.coin-sym {
  display: inline-flex; padding: 2px 7px;
  background: var(--accent-light); color: var(--accent);
  border-radius: 5px; font-size: 12px; font-weight: 700;
  font-family: 'SF Mono', monospace;
}

.especes-row td { color: var(--text-3); font-style: italic; font-size: 12.5px; }

/* ── PER ── */
.per-card { padding: 20px; }

.per-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
}

.per-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.per-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.per-total { text-align: right; }
.per-val   { font-size: 1.35rem; font-weight: 700; }
.per-perf  { font-size: 13px; margin-top: 2px; }

.fonds-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }

.fond-row {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
}

.fond-name {
  flex: 1; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.fond-bar-wrap {
  width: 100px; height: 4px;
  background: var(--border); border-radius: 2px; flex-shrink: 0;
}

.fond-bar { height: 100%; background: #6366F1; border-radius: 2px; }

.fond-pct { width: 34px; text-align: right; color: var(--text-3); font-size: 11px; }
.fond-val { width: 75px; text-align: right; font-weight: 500; }

.per-footer {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-3);
  border-top: 1px solid var(--border);
  padding-top: 10px; margin-top: 4px;
}

/* ── Immobilier ── */
.bien-card { padding: 20px; }

.bien-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
}

.bien-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.bien-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.bien-equity-val { font-size: 1.35rem; font-weight: 700; text-align: right; }
.bien-equity-lbl { font-size: 11px; color: var(--text-3); text-align: right; }

.bien-values {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.vitem { display: flex; flex-direction: column; gap: 1px; }
.vl { font-size: 10.5px; color: var(--text-3); }
.vv { font-size: 13.5px; font-weight: 500; }

.credit-block {
  background: #FFF7ED;
  border-radius: 9px; padding: 14px; margin-top: 6px;
}

.credit-title {
  font-size: 11.5px; font-weight: 600; color: #C2410C; margin-bottom: 10px;
}

.credit-values {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px; margin-bottom: 12px;
}

.progress-wrap { display: flex; align-items: center; gap: 10px; }

.progress-bar {
  flex: 1; height: 5px;
  background: rgba(194,65,12,.2);
  border-radius: 3px; overflow: hidden;
}

.progress-fill {
  height: 100%; background: #EA580C; border-radius: 3px;
}

.progress-label { font-size: 11px; color: #9A3412; white-space: nowrap; }

/* ── Épargne ── */
.epargne-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px;
}

.epargne-name { font-size: 14px; font-weight: 500; margin-bottom: 5px; }
.epargne-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.epargne-solde { font-size: 18px; font-weight: 700; white-space: nowrap; }

.subsection-title {
  font-size: 11.5px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 0;
}

/* ── Famille ── */
.famille-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.membre-card { padding: 18px; }

.membre-header {
  display: flex; align-items: center; gap: 12px;
  padding-bottom: 14px; margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.membre-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.membre-info { flex: 1; }
.membre-nom  { font-size: 14px; font-weight: 600; }
.membre-pct  { font-size: 11px; color: var(--text-3); }
.membre-total { font-size: 16px; font-weight: 700; white-space: nowrap; }

.membre-cats { display: flex; flex-direction: column; gap: 7px; }

.membre-cat-row {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
}

.membre-cat-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.membre-cat-label { width: 100px; color: var(--text-2); flex-shrink: 0; font-size: 12px; }

.membre-cat-bar-wrap {
  flex: 1; height: 4px;
  background: var(--border); border-radius: 2px; overflow: hidden;
}

.membre-cat-bar { height: 100%; border-radius: 2px; }

.membre-cat-val { width: 70px; text-align: right; font-weight: 500; flex-shrink: 0; font-size: 12.5px; }

/* ── Dividendes ── */
.div-summary {
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--border);
}

/* ── Loading ── */
.loading-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 60vh; gap: 14px; color: var(--text-3);
}

.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utils ── */
.text-muted { color: var(--text-3); }
.small { font-size: 11px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
