/* ── android-overrides ───────────────────────────────────────────────────── */
  /* supprime le délai 300ms sur mobile */
  * { touch-action: manipulation; }
  /* élimine le highlight bleu au tap */
  * { -webkit-tap-highlight-color: transparent; }
  /* safe-area iOS/Android notch */
  body { padding-bottom: env(safe-area-inset-bottom, 0); }
  /* pull-to-refresh natif confié à l'hôte Android */
  html { overscroll-behavior-y: contain; }
  /* améliore le rendu des fonts */
  * { -webkit-font-smoothing: antialiased; }

/* ── app-nav-css ─────────────────────────────────────────────────────────── */
  :root { --app-nav-h: 72px; }

  /* ── Page nav system ── */
  .app-page { display: none; }
  .app-page.active { display: block; }

  /* Extra bottom padding so content isn't hidden behind nav */
  main { padding-bottom: calc(var(--app-nav-h) + .75rem) !important; }

  /* ── Bottom navigation bar ── */
  .app-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    background: #fff;
    border-top: 1.5px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    min-height: 60px;
    height: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
    visibility: visible;
    opacity: 1;
    transform: translate3d(0,0,0);
    -webkit-transform: translate3d(0,0,0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    will-change: transform;
  }

  .app-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 2px;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s;
    min-width: 0;
    width: 100%;
  }

  .app-nav-btn:active { background: rgba(193,39,45,0.06); }

  .app-nav-icon {
    font-size: 1.35rem;
    line-height: 1;
    transition: transform .2s;
  }

  .app-nav-btn.active .app-nav-icon { transform: scale(1.18); }

  .app-nav-label {
    font-size: .58rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--ink-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .app-nav-btn.active .app-nav-label { color: var(--red); }

  @media (max-width: 390px) {
    .app-nav-icon { font-size: 1.2rem; }
    .app-nav-label { font-size: .54rem; }
    .app-nav-btn { padding: 6px 1px; }
  }

  /* Active indicator dot */
  .app-nav-btn.active::after {
    content: '';
    display: block;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--red);
    margin-top: 2px;
  }

  /* Page transition */
  .app-page.active {
    animation: pageIn .2s ease;
  }
  @keyframes pageIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

/* ── espace-rebuild-css ──────────────────────────────────────────────────── */
  /* ── Espace sections ── */
  .espace-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 2px 10px var(--shadow);
    margin-bottom: 1.2rem;
    overflow: hidden;
  }

  .espace-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.3rem;
    background: var(--cream);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .espace-card-title {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .9rem;
    font-weight: 700;
    color: var(--ink);
    font-family: var(--font-display);
  }

  .espace-card-icon { font-size: 1.15rem; }

  .espace-toggle-btn {
    background: none;
    border: none;
    font-size: .75rem;
    color: var(--ink-faint);
    cursor: pointer;
    padding: .38rem .62rem;
    min-width: 40px;
    min-height: 40px;
    border-radius: 6px;
    transition: transform .2s;
    -webkit-tap-highlight-color: transparent;
  }

  .espace-toggle-btn.collapsed { transform: rotate(-90deg); }

  .espace-card-body {
    padding: 1.2rem 1.3rem;
    transition: none;
  }

  .espace-card-body.collapsed { display: none; }

  /* ── KPI row grid ── */
  .port-kpi-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
    margin-bottom: 1rem;
  }

  /* ── Mobile holding cards (remplace la table) ── */
  .holding-card {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .8rem 1rem;
    margin-bottom: .5rem;
    position: relative;
  }

  .holding-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .45rem;
  }

  .holding-ticker-badge {
    font-size: .72rem;
    font-weight: 800;
    background: var(--ink);
    color: #fff;
    border-radius: 6px;
    padding: .15rem .5rem;
    letter-spacing: .04em;
  }

  .holding-name {
    font-size: .74rem;
    color: var(--ink-muted);
    flex: 1;
    margin: 0 .6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .holding-del-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ink-faint);
    font-size: .85rem;
    padding: .32rem .45rem;
    min-width: 36px;
    min-height: 36px;
    border-radius: 4px;
    -webkit-tap-highlight-color: transparent;
  }

  .holding-del-btn:active { color: var(--red); }

  .holding-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: .72rem;
    color: var(--ink-muted);
    margin-top: .2rem;
  }

  .holding-row strong { color: var(--ink); }

  .holding-pnl-bar {
    height: 4px;
    border-radius: 3px;
    background: var(--border);
    overflow: hidden;
    margin-top: .5rem;
  }

  .holding-pnl-fill {
    height: 100%;
    border-radius: 3px;
    transition: width .5s ease;
  }

  /* ── Action buttons ── */
  .espace-actions {
    display: flex;
    gap: .6rem;
    margin-top: .9rem;
    flex-wrap: wrap;
  }

  .espace-btn {
    flex: 1;
    min-width: 120px;
    border: none;
    border-radius: 10px;
    padding: .6rem .9rem;
    font-size: .74rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
    text-align: center;
  }

  .espace-btn-green  { background: var(--green); color: #fff; }
  .espace-btn-red    { background: var(--red);   color: #fff; }
  .espace-btn-purple { background: linear-gradient(135deg,#7c3aed,#a855f7); color: #fff; }
  .espace-btn-ghost  { background: var(--cream); color: var(--ink-muted); border: 1px solid var(--border); }

  .espace-empty {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--ink-faint);
    font-size: .78rem;
    line-height: 1.6;
  }

  /* ── Sim holding cards ── */
  .sim-holding-card {
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .75rem 1rem;
    margin-bottom: .45rem;
    display: flex;
    align-items: center;
    gap: .6rem;
  }

  .sim-holding-info { flex: 1; min-width: 0; }
  .sim-holding-name { font-size: .7rem; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sim-holding-vals { text-align: right; white-space: nowrap; }

/* ── desktop-css ─────────────────────────────────────────────────────────── */
  /* Sidebar masquée par défaut (mobile) */
  #desktop-sidebar { display: none; }
  #desktop-section-header { display: none; }

  @media (min-width: 1024px) {
    :root {
      --sidebar-w: 240px;
      --content-max: 1400px;
    }

    body {
      overflow-x: hidden;
    }

    /* Header plus compact en mode desktop */
    header {
      padding: 0 1.5rem 0 calc(var(--sidebar-w) + 1.5rem) !important;
    }
    .header-inner {
      max-width: none;
      padding: 1rem 0 !important;
    }
    .logo-text h1 { font-size: 1.5rem !important; }
    .logo-text span { font-size: .72rem; }
    .logo-emblem { width: 42px !important; height: 42px !important; font-size: 1.3rem !important; }

    /* Ticker bar full-width sous le header */
    .ticker-bar { padding-left: var(--sidebar-w); }

    /* SIDEBAR */
    #desktop-sidebar {
      display: flex;
      flex-direction: column;
      position: fixed;
      top: 0; left: 0; bottom: 0;
      width: var(--sidebar-w);
      background: linear-gradient(180deg, #8B0D12 0%, #6f0a0e 100%);
      color: #fff;
      z-index: 300;
      box-shadow: 2px 0 16px rgba(0,0,0,0.15);
      padding: 1rem 0;
      overflow-y: auto;
    }
    #desktop-sidebar .sb-brand {
      display: flex; align-items: center; gap: .7rem;
      padding: .8rem 1.2rem 1.4rem;
      border-bottom: 1px solid rgba(255,255,255,0.12);
      margin-bottom: 1rem;
    }
    #desktop-sidebar .sb-brand-emblem {
      width: 38px; height: 38px;
      background: rgba(255,255,255,0.12);
      border: 1px solid rgba(255,255,255,0.25);
      border-radius: 10px;
      display: flex; align-items: center; justify-content: center;
      font-size: 1.2rem;
    }
    #desktop-sidebar .sb-brand-text { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; letter-spacing: -.01em; }
    #desktop-sidebar .sb-brand-sub { font-size: .62rem; color: rgba(255,255,255,0.7); letter-spacing: .04em; text-transform: uppercase; }

    #desktop-sidebar .sb-nav {
      display: flex; flex-direction: column; gap: .15rem;
      padding: 0 .7rem;
      flex: 1;
    }
    #desktop-sidebar .sb-nav-item {
      display: flex; align-items: center; gap: .8rem;
      padding: .7rem 1rem;
      border-radius: 10px;
      color: rgba(255,255,255,0.82);
      cursor: pointer;
      text-decoration: none;
      font-size: .85rem;
      font-weight: 500;
      transition: background .15s, color .15s, transform .15s;
      border: none;
      background: transparent;
      text-align: left;
      width: 100%;
      font-family: inherit;
    }
    #desktop-sidebar .sb-nav-item:hover {
      background: rgba(255,255,255,0.08);
      color: #fff;
    }
    #desktop-sidebar .sb-nav-item.active {
      background: rgba(255,255,255,0.16);
      color: #fff;
      font-weight: 600;
      box-shadow: inset 3px 0 0 var(--gold);
    }
    #desktop-sidebar .sb-nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

    #desktop-sidebar .sb-section-title {
      font-size: .6rem;
      letter-spacing: .12em;
      text-transform: uppercase;
      color: rgba(255,255,255,0.5);
      padding: 1rem 1.5rem .4rem;
      font-weight: 600;
    }

    /* Footer sidebar : info utilisateur */
    #desktop-sidebar .sb-footer {
      margin-top: auto;
      padding: 1rem .7rem .3rem;
      border-top: 1px solid rgba(255,255,255,0.12);
    }
    #desktop-sidebar .sb-user {
      display: flex; align-items: center; gap: .6rem;
      padding: .5rem .8rem;
      border-radius: 10px;
      font-size: .78rem;
      color: rgba(255,255,255,0.9);
    }
    #desktop-sidebar .sb-user-avatar {
      width: 32px; height: 32px;
      background: var(--gold);
      color: #5a0408;
      border-radius: 50%;
      display: flex; align-items: center; justify-content: center;
      font-weight: 700;
      font-size: .85rem;
    }

    /* Hide mobile bottom nav */
    .app-nav { display: none !important; }

    /* Hide the user-menu-btn in header (info already in sidebar) */
    #user-menu-btn { display: none !important; }
    #user-dropdown { display: none !important; }

    /* Show ALL pages simultaneously, with section headers */
    .app-page { display: block !important; opacity: 1 !important; transform: none !important; animation: none !important; }
    .app-page::before {
      content: attr(data-section-title);
      display: block;
      font-family: var(--font-display);
      font-size: 2rem;
      font-weight: 700;
      color: var(--ink);
      letter-spacing: -.02em;
      margin: 2.5rem 0 1.2rem;
      padding-bottom: .8rem;
      border-bottom: 2px solid var(--border);
      position: relative;
    }
    .app-page::after {
      content: '';
      position: absolute;
      bottom: -2px; left: 0;
      width: 60px; height: 2px;
      background: var(--red);
    }
    #page-1::before { margin-top: 1.2rem; }
    /* Pseudo-elements positioning fix */
    .app-page { position: relative; }

    /* MAIN content area positioned to the right of sidebar */
    main {
      margin-left: var(--sidebar-w);
      max-width: var(--content-max);
      padding: 1.5rem 2rem !important;
      padding-bottom: 3rem !important;
    }

    /* Page-1 (Marché) : grid 2 colonnes pour overview + news */
    #page-1 > section:first-of-type {
      max-width: none;
    }

    /* Espace : grid 3 cartes côte-à-côte (portfolio | alertes | simulateur) */
    #page-5 .espace-card-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 1.2rem;
    }

    /* Cards plus aérées */
    .card, .indice-card, .news-card {
      box-shadow: 0 4px 18px rgba(28,25,23,0.06);
    }

    /* Scroll smooth pour les ancres */
    html { scroll-behavior: smooth; scroll-padding-top: 1rem; }
  }

  @media (min-width: 1440px) {
    :root { --sidebar-w: 260px; }
    main { padding: 2rem 3rem !important; padding-bottom: 4rem !important; }
  }
