/* Application web ImCIOBitch. Les couleurs viennent de ../assets/tokens.css. */

h1,
h2,
p,
ul,
dl,
dd,
figure {
  margin: 0;
}
ul {
  padding: 0;
  list-style: none;
}
[hidden] {
  display: none !important;
}

.num,
.table td,
.table th.num {
  font-variant-numeric: tabular-nums;
}
.caption {
  color: var(--muted);
  font-size: 0.85rem;
}
.label {
  color: var(--ink-2);
  font-size: 0.9rem;
}
.is-muted {
  color: var(--muted);
}

/* ------------------------------------------------------------------ Ossature */

.shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.sidebar .brand {
  padding: 0 8px;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--ink-2);
  font-weight: 550;
  text-decoration: none;
}
.nav-link:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.sidebar-user {
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.content {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.9rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
  color: var(--ink-2);
  font-size: 0.9rem;
  text-decoration: none;
}
.back-link:hover {
  color: var(--ink);
}
.back-link .icon {
  width: 16px;
  height: 16px;
}

.loading,
.placeholder {
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}
.noscript {
  max-width: 32rem;
  margin: 20vh auto;
  padding: 0 24px;
  text-align: center;
}

/* ------------------------------------------------------------------ Cartes */

.card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card + .card,
.card + .filters,
.kpis + .filters,
.dashboard-grid + .card,
.detail-grid + .card,
.toggle + .card {
  margin-top: 16px;
}
.card h2 {
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}
.card-header a {
  font-size: 0.9rem;
  font-weight: 550;
}
.list-card {
  padding: 0;
  overflow: hidden;
}
.list-card > .card-header {
  margin: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.category-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Le total prend la place disponible ; les tuiles passent à la ligne quand l'écran rétrécit */
.kpis {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.kpis .card + .card {
  margin-top: 0;
}
.kpis .hero {
  flex: 1.6 1 380px;
}
.kpis .tile {
  flex: 1 1 230px;
}
.hero {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
/* Le chiffre vedette : même police que le reste, chiffres proportionnels */
.hero-value {
  font-size: clamp(2rem, 4.4vw, 3.2rem);
  white-space: nowrap;
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.note {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  white-space: pre-wrap;
}
.tile {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}
.tile-value .delta {
  flex-wrap: wrap;
  font-size: 1.15rem;
  white-space: normal;
}

.filters {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.filters-label {
  color: var(--ink-2);
  font-size: 0.9rem;
}
.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
}
.segmented button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
}
.segmented button.is-selected {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
}
.detail-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(0, 1.7fr);
  gap: 16px;
  align-items: start;
}
.dashboard-grid .card + .card,
.detail-grid .card + .card {
  margin-top: 0;
}

/* ------------------------------------------------------------------ Variations */

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.delta .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}
.delta-up {
  color: var(--gain);
}
.delta-down {
  color: var(--loss);
}
.delta-flat {
  color: var(--muted);
}
.delta-small {
  font-size: 0.85rem;
}
.delta-small .icon {
  width: 13px;
  height: 13px;
}

/* ------------------------------------------------------------------ Répartition */

.swatch {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: var(--swatch-size);
  height: var(--swatch-size);
  border-radius: calc(var(--swatch-size) * 0.28);
  background: var(--swatch);
  color: #fff;
}
.swatch .icon {
  width: calc(var(--swatch-size) * 0.56);
  height: calc(var(--swatch-size) * 0.56);
  stroke-width: 2;
}
/* Segments séparés par un espace de la couleur du fond, sans contour */
.allocation-bar {
  display: flex;
  gap: 2px;
  height: 14px;
  border-radius: 7px;
  overflow: hidden;
}
.allocation-bar span {
  min-width: 2px;
}
.shares {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 18px;
}
.shares li {
  display: flex;
  align-items: center;
  gap: 12px;
}
.share-name {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.share-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-variant-numeric: tabular-nums;
}
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ------------------------------------------------------------------ Graphiques */

.chart {
  outline-offset: 6px;
}
.chart-frame {
  position: relative;
}
.chart-plot {
  touch-action: pan-y;
}
.chart-svg {
  display: block;
  overflow: visible;
}
.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}
.chart-axis {
  fill: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-area {
  opacity: 0.1;
}
.chart-crosshair {
  stroke: var(--line-strong);
  stroke-width: 1;
}
.chart-dot {
  stroke: var(--surface);
  stroke-width: 2;
}
.chart-tooltip {
  position: absolute;
  top: 0;
  z-index: 2;
  min-width: 150px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  pointer-events: none;
  transform: translateX(14px);
  white-space: nowrap;
}
.chart-tooltip.is-flipped {
  transform: translateX(calc(-100% - 14px));
}
.chart-tooltip-date {
  margin-bottom: 6px;
  color: var(--ink-2);
}
.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.chart-tooltip-name {
  color: var(--ink-2);
}
/* Clé de légende : un court trait de la couleur de la série */
.chart-key {
  flex: none;
  width: 14px;
  height: 3px;
  border-radius: 2px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 0.85rem;
}
.chart-legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.chart-table {
  margin-top: 12px;
  font-size: 0.9rem;
}
.chart-table summary {
  display: inline-block;
  color: var(--ink-2);
  cursor: pointer;
}
.chart-table summary:hover {
  color: var(--ink);
}
.chart-table .table-scroll {
  max-height: 280px;
  margin-top: 8px;
  overflow: auto;
}
.chart-table table {
  width: 100%;
  border-collapse: collapse;
}
.chart-table th,
.chart-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}
.chart-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 550;
}
.chart-table .num {
  text-align: right;
}

/* ------------------------------------------------------------------ Listes et tableaux */

.rows li + li {
  border-top: 1px solid var(--line);
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  color: inherit;
  text-decoration: none;
}
a.row:hover {
  background: var(--surface-2);
}
.row-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}
.row-title {
  font-weight: 550;
  overflow-wrap: anywhere;
}
.row-value {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.row-chevron {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.row-actions {
  display: flex;
  gap: 2px;
}
.icon-up {
  transform: rotate(-90deg);
}
.icon-down {
  transform: rotate(90deg);
}

.table-scroll {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
.table thead th {
  border-top: 0;
  color: var(--ink-2);
  font-size: 0.85rem;
  font-weight: 550;
}
.table tbody th {
  font-weight: 550;
}
.table .num {
  text-align: right;
}
.table .actions {
  width: 1%;
  text-align: right;
}
.table a {
  color: inherit;
  text-decoration: none;
}
.table-clickable tbody tr {
  cursor: pointer;
}
.table-clickable tbody tr:hover {
  background: var(--surface-2);
}
.top-assets {
  padding: 0;
  overflow: hidden;
}
.top-assets > .card-header {
  margin: 0;
  padding: 16px 20px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--ink-2);
  font-size: 0.9rem;
  cursor: pointer;
}
.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 30rem;
  margin: 10vh auto 0;
  text-align: center;
}
.empty h2 {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}
.empty p {
  color: var(--ink-2);
}
.empty .btn {
  margin-top: 8px;
}
.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
}
.empty-icon .icon {
  width: 30px;
  height: 30px;
}

/* ------------------------------------------------------------------ Formulaires */

.form,
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 0.9rem;
  font-weight: 550;
}
.field-hint {
  color: var(--muted);
  font-size: 0.85rem;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 0;
}
textarea.input {
  resize: vertical;
}
.input-code {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.number-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.input-number {
  width: 9.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.number-unit {
  min-width: 1.2rem;
  color: var(--muted);
}
.form-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--loss) 10%, transparent);
  color: var(--loss);
  font-size: 0.9rem;
}
.btn-block {
  width: 100%;
}
.computed {
  color: var(--ink-2);
}
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.icon-button:hover:not([disabled]) {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-button[disabled] {
  opacity: 0.3;
  cursor: default;
}
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ------------------------------------------------------------------ Fenêtres modales */

.modal {
  width: min(30rem, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0 20px;
}
.modal-header h2 {
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}
.modal-body {
  padding: 16px 20px;
}
.modal-text {
  color: var(--ink-2);
}
.modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px 20px;
}
.modal-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.picker {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.picker button {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 0;
  cursor: pointer;
}
.picker-color {
  border-radius: 50%;
  color: #fff;
}
.picker-icon {
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 50;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--page);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

/* ------------------------------------------------------------------ Saisie d'un relevé */

.editor-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 12px 20px;
}
.editor-row + .editor-row {
  border-top: 1px solid var(--line);
}
.editor-row .input[type="date"] {
  width: auto;
}
.editor .field-hint {
  padding: 0 20px 14px;
}
.editor-quantity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.editor-quantity .input-number {
  width: 7rem;
}
.editor-computed {
  min-width: 6.5rem;
  text-align: right;
}
.editor-bar {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 14px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}
.editor-bar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}
.editor-total {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
}
.editor-total-value {
  font-size: 1.4rem;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ Réglages */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.settings-grid .card + .card {
  margin-top: 0;
}
.settings-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}
.settings-wide {
  grid-row: span 3;
  align-items: stretch;
}
.settings-wide .card-header {
  margin: 0;
}
.settings-wide .row {
  padding: 12px 0;
}
.definitions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  width: 100%;
}
.definitions dt {
  color: var(--ink-2);
}
.definitions dd {
  overflow-wrap: anywhere;
}
.button-row,
.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

/* ------------------------------------------------------------------ Connexion */

.auth {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  min-height: 100vh;
  padding: 8vh 16px 32px;
}
.auth-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(26rem, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-card h1 {
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}
.auth-intro {
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  font-size: 0.95rem;
}
.auth-note,
.auth-legal {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ------------------------------------------------------------------ Tuiles chiffrées */

.tile-number {
  font-size: 1.5rem;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.tile-extra {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 0.9rem;
}
/* ------------------------------------------------------------------ Synthèse */

/* Cartes de la synthèse : coins plus ronds, légère profondeur */
.dash .card {
  border-radius: 22px;
  box-shadow: 0 1px 2px rgba(11, 11, 11, 0.03), 0 12px 28px -18px rgba(11, 11, 11, 0.18);
}

/* Haut de page : le patrimoine et sa courbe, et à côté ce qui le compose */
.overview {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.overview.has-side {
  grid-template-columns: minmax(0, 1.85fr) minmax(300px, 1fr);
}
.overview-side {
  display: grid;
  grid-auto-rows: 1fr;
  gap: 16px;
}
.overview .card + .card {
  margin-top: 0;
}

/* Bloc principal : toujours sombre, à l'image de l'icône (courbe dorée sur fond anthracite).
   Les couleurs de texte et de variation sont donc celles du thème sombre, quel que soit le thème. */
.dash .hero-modern {
  --ink: #ffffff;
  --ink-2: #cfcbbd;
  --muted: #98958a;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #ebbc46;
  --gain: #2fbf4a;
  --loss: #f07a7a;
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background:
    radial-gradient(110% 80% at 100% 0%, rgba(235, 188, 70, 0.24), transparent 58%),
    radial-gradient(90% 70% at 0% 100%, rgba(235, 188, 70, 0.07), transparent 60%),
    linear-gradient(155deg, #211d15 0%, #141311 52%, #0e0d0c 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07), 0 28px 60px -30px rgba(32, 24, 4, 0.75);
  color: var(--ink);
  overflow: hidden;
}
.hero-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 28px 28px 0;
}
/* Le texte change au survol de la courbe : c'est lui qui passe à la ligne, pas les boutons */
.hero-headline {
  flex: 1;
  min-width: 0;
}
.hero-top .segmented {
  flex: none;
}
.hero-label {
  color: var(--ink-2);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.hero-date {
  margin-left: 10px;
  color: var(--muted);
  font-weight: 450;
  letter-spacing: 0;
  text-transform: none;
}
.hero-modern .hero-value {
  margin-top: 4px;
  font-size: clamp(2.3rem, 5.2vw, 3.9rem);
  font-weight: 680;
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.hero-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 0.9rem;
}
/* Variation en pastille : même flèche, même signe, sur un fond teinté de sa couleur */
.delta-pill {
  padding: 4px 11px 4px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 17%, transparent);
}
/* Boutons de période sur fond sombre */
.hero-modern .segmented {
  background: rgba(255, 255, 255, 0.08);
}
.hero-modern .segmented button {
  color: var(--ink-2);
}
.hero-modern .segmented button.is-selected {
  background: rgba(255, 255, 255, 0.17);
  box-shadow: none;
  color: var(--ink);
}

/* La courbe : en arrière-plan, bord à bord, glissée sous le chiffre */
/* Elle prend toute la hauteur restante du bloc, quand les cartes voisines l'étirent */
.hero-chart {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  margin: -18px 0 0;
  outline-offset: -6px;
}
.hero-plot {
  position: relative;
  flex: 1;
  min-height: 190px;
  touch-action: pan-y;
  cursor: crosshair;
}
/* Hors du flux : c'est le bloc qui fixe la taille du tracé, jamais l'inverse */
.hero-svg {
  position: absolute;
  inset: 0;
}
.hero-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hero-stop-top {
  stop-color: var(--accent);
  stop-opacity: 0.3;
}
.hero-stop-bottom {
  stop-color: var(--accent);
  stop-opacity: 0;
}
.hero-dot {
  fill: var(--accent);
  stroke: #17150f;
  stroke-width: 3;
}
.hero-halo {
  fill: var(--accent);
  opacity: 0.22;
  transform-box: fill-box;
  transform-origin: center;
  animation: hero-pulse 2.8s ease-in-out infinite;
}
@keyframes hero-pulse {
  0%,
  100% {
    opacity: 0.22;
    transform: scale(0.8);
  }
  50% {
    opacity: 0.08;
    transform: scale(1.35);
  }
}
.hero-crosshair {
  stroke: rgba(255, 255, 255, 0.4);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}
.hero-axis {
  display: flex;
  justify-content: space-between;
  padding: 0 28px 14px;
  color: var(--muted);
  font-size: 0.75rem;
}

/* Variations du patrimoine sur trois périodes, au pied du bloc */
.hero-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}
.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 28px 20px;
  min-width: 0;
}
.hero-stat + .hero-stat {
  border-left: 1px solid var(--line);
}
.hero-stat dt {
  color: var(--ink-2);
  font-size: 0.8rem;
}
.hero-stat dd {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
}
.hero-stat .delta {
  font-size: 1.2rem;
}
.hero-stat-amount {
  color: var(--ink-2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.hero-stat-since {
  color: var(--muted);
  font-size: 0.75rem;
}
.only-narrow {
  display: none;
}
.variation-none {
  color: var(--muted);
  font-weight: 550;
}

/* Un patrimoine : valeur, part du global, allure de sa courbe, variations */
.wealth {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}
.wealth-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.label-dot {
  display: flex;
  align-items: center;
  gap: 8px;
}
.wealth-share {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 0.78rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.wealth-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.wealth-change {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  margin-top: 2px;
}
.sparkline {
  flex: none;
  width: 120px;
  height: 44px;
  overflow: visible;
}
.sparkline-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.wealth-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.wealth-stat {
  min-width: 0;
}
.wealth-stat dt {
  color: var(--muted);
  font-size: 0.75rem;
}
.wealth-stat dd {
  display: flex;
  flex-direction: column;
  margin: 2px 0 0;
}
.wealth-stat-amount {
  color: var(--ink-2);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.wealth-note {
  margin-top: -4px;
  font-size: 0.75rem;
}
/* Courbe détaillée : type de courbe et période, côte à côte */
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ------------------------------------------------------------------ Objectifs, projection */

/* Onglets d'une rubrique : mêmes formes que les boutons exclusifs, en liens */
.tabs {
  display: inline-flex;
  max-width: 100%;
  margin-bottom: 20px;
  padding: 3px;
  border-radius: 12px;
  background: var(--surface-2);
  overflow-x: auto;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  color: var(--ink-2);
  font-size: 0.92rem;
  font-weight: 550;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a.is-selected {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}
.goal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.goal-grid .card + .card {
  margin-top: 0;
}
.goal-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.goal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.goal-head h2 {
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}
.goal-figure {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.goal-figure strong {
  color: var(--ink);
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
/* Dans une colonne, la jauge garde sa hauteur et prend toute la largeur */
.meter.goal-meter {
  flex: none;
  width: 100%;
  height: 10px;
  border-radius: 5px;
}
.meter.goal-meter.is-reached {
  background: color-mix(in srgb, var(--gain) 18%, transparent);
}
.meter.goal-meter.is-reached span {
  background: var(--gain);
}
.goal-rest {
  font-weight: 550;
  font-variant-numeric: tabular-nums;
}
/* État d'un objectif : toujours une icône et un texte, la couleur ne fait que souligner */
.goal-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}
.goal-state.is-good {
  color: var(--gain);
}
.goal-state.is-late {
  color: var(--loss);
}
.goal-rows {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  list-style: none;
}
.goal-rows li {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.goal-row-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.goal-row-head strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.projection-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px 24px;
  align-items: start;
  margin-bottom: 16px;
}
.projection-results > * + * {
  margin-top: 16px;
}
.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
/* Rappels (réglages) : la case, puis « le [jour] du mois » */
.reminder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  width: 100%;
}
.reminder .toggle {
  margin-bottom: 0;
  color: var(--ink);
}
.reminder .caption {
  flex-basis: 100%;
}
.reminder-day {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 0.9rem;
}
.input-day {
  width: auto;
  min-height: 36px;
  padding: 4px 8px;
}

/* Invitation à ajouter un bien immobilier, à la place des tuiles qu'il fera apparaître */
.tile-text {
  color: var(--ink-2);
  font-size: 0.9rem;
}
.tile-actions,
.empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tile-actions {
  margin-top: 6px;
}
.empty-actions {
  justify-content: center;
}
.icon-inline {
  width: 15px;
  height: 15px;
}
.section-heading {
  margin: 40px 0 16px;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}
.card-header-end {
  display: flex;
  align-items: center;
  gap: 8px;
}
.placeholder-small {
  padding: 20px 16px;
}

/* ------------------------------------------------------------------ Finances mensuelles */

.month-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-bottom: 16px;
}
.month-nav-label {
  min-width: 10.5rem;
  font-size: 1.15rem;
  text-align: center;
}
.month-nav .btn {
  margin-left: 8px;
}
.kpis + .list-card,
.kpis + .card {
  margin-top: 16px;
}
.budget-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 20px;
}
.budget-check {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 12rem;
  cursor: pointer;
}
.budget-check input {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}
.budget-row.is-done .row-title {
  color: var(--ink-2);
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}
/* Dépense variable : nom, montants et crayon sur une ligne ; la jauge en dessous */
.budget-row.budget-variable {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "main amounts edit" "progress progress progress";
}
.budget-variable .row-main {
  grid-area: main;
}
.budget-variable .budget-amounts {
  grid-area: amounts;
}
.budget-variable > .icon-button {
  grid-area: edit;
}
.budget-variable .budget-progress {
  grid-area: progress;
}
.budget-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.budget-amount {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.budget-amounts .input-number {
  width: 7.5rem;
}
.budget-progress {
  display: flex;
  flex-basis: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}
/* Jauge : la piste est une teinte plus claire de la couleur de remplissage */
.meter {
  flex: 1;
  min-width: 8rem;
  height: 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--s1) 18%, transparent);
  overflow: hidden;
}
.meter span {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--s1);
}
.meter.is-over {
  background: color-mix(in srgb, var(--loss) 18%, transparent);
}
.meter.is-over span {
  background: var(--loss);
}
.meter-note {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.meter-note.is-over {
  color: var(--loss);
  font-weight: 600;
}
.meter-scale {
  display: flex;
  justify-content: space-between;
}

.chart-bar.is-dimmed {
  opacity: 0.45;
}
.chart-key-block {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.chart-tooltip-total {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------------ Conseils */

.advice-intro {
  max-width: 48rem;
  margin-bottom: 24px;
  color: var(--ink-2);
}
.advice-intro strong {
  color: var(--ink);
}
.advice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.advice-grid .card + .card {
  margin-top: 0;
}
.advice-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.advice-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.advice-title h2 {
  font-size: 1.15rem;
}
.feature-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.advice-text {
  color: var(--ink-2);
}
.advice-yours {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--page);
}
.advice-yours-title {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* Dans une colonne, la jauge garde sa hauteur et prend toute la largeur */
.advice-yours .meter {
  flex: none;
  width: 100%;
}
.advice-figure {
  font-size: 1.2rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.advice-missing {
  color: var(--ink-2);
}
.advice-age {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 550;
}
.advice-age .input-number {
  width: 5.5rem;
}
.compare-bars {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px 12px;
}
.table-compact th,
.table-compact td {
  padding: 8px 0 8px 16px;
  font-size: 0.92rem;
}
.table-compact th:first-child,
.table-compact td:first-child {
  padding-left: 0;
}
.table-compact tbody th {
  font-weight: 500;
}
.table-compact .category-chip {
  color: var(--ink);
}

/* ------------------------------------------------------------------ Écrans étroits */

@media (max-width: 1180px) {
  .overview.has-side {
    grid-template-columns: minmax(0, 1fr);
  }
  .overview-side {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    grid-auto-rows: auto;
  }
  .dashboard-grid,
  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1020px) {
  .settings-grid,
  .advice-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .settings-wide {
    grid-row: auto;
  }
}

@media (max-width: 780px) {
  .hero-top {
    flex-direction: column;
    padding: 22px 20px 0;
  }
  /* Deux lignes réservées : la hauteur ne bouge pas quand on parcourt la courbe au doigt */
  .hero-context {
    min-height: 3.4em;
    align-content: flex-start;
  }
  .hero-chart {
    margin-top: 0;
  }
  .hero-plot {
    min-height: 150px;
  }
  .hero-axis {
    padding: 0 20px 12px;
  }
  .hero-stat {
    padding: 14px 12px 16px;
  }
  .hero-stat:first-child {
    padding-left: 20px;
  }
  .only-wide {
    display: none;
  }
  .only-narrow {
    display: inline;
  }
  .hero-stat .delta {
    font-size: 1rem;
  }
  .hero-stat .delta .icon {
    display: none;
  }
  .hero-stat dt,
  .hero-stat-amount {
    font-size: 0.75rem;
  }
  .hero-stat-since {
    font-size: 0.68rem;
  }
  .goal-grid,
  .goal-rows {
    grid-template-columns: minmax(0, 1fr);
  }
  .shell {
    display: block;
  }
  /* La navigation passe en bas de l'écran, comme dans l'app iPhone */
  .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10;
    flex-direction: row;
    height: auto;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-right: 0;
  }
  .sidebar .brand,
  .sidebar-user {
    display: none;
  }
  .nav {
    flex: 1;
    flex-direction: row;
    justify-content: space-around;
  }
  .nav-link {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    padding: 6px 2px;
    font-size: 0.66rem;
  }
  .content {
    padding: 20px 16px 110px;
  }
  .page-header h1 {
    font-size: 1.6rem;
  }
  .kpis .hero {
    flex-basis: 100%;
  }
  .card {
    padding: 16px;
  }
  .list-card,
  .top-assets {
    padding: 0;
  }
  .table th,
  .table td {
    padding: 10px 14px;
  }
  .table-compact th,
  .table-compact td {
    padding: 8px 0 8px 12px;
  }
  .row,
  .editor-row,
  .budget-row {
    padding: 12px 16px;
  }
  .month-nav-label {
    min-width: 0;
    flex: 1;
  }
  /* Tuiles deux par deux ; montants des dépenses variables côte à côte sous le nom */
  .kpis .tile {
    flex: 1 1 150px;
  }
  .tile-number {
    font-size: 1.25rem;
  }
  .budget-row.budget-variable {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "main edit" "amounts amounts" "progress progress";
  }
  .budget-amounts {
    flex-wrap: nowrap;
  }
  .budget-amount {
    flex: 1;
    min-width: 0;
  }
  .budget-amounts .number-field {
    display: flex;
  }
  .budget-amounts .input-number {
    width: 100%;
    min-width: 0;
  }
  .settings-wide .row {
    padding: 12px 0;
  }
  .editor-bar {
    bottom: calc(64px + env(safe-area-inset-bottom));
  }
  .toast {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .input-number {
    width: 8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-halo {
    animation: none;
  }
  * {
    transition: none !important;
  }
}
