:root {
  --page:#f6f7fa; --panel:#ffffff; --hover:#f1f2f6; --hairline:#e7e8ee;
  --ink:#26272e; --ink-2:#5d5f6b; --muted:#8b8d99;
  --accent:#5147d6; --accent-bg:#edecfb;
  --up:#006300; --up-bg:#e7f3e7; --down:#c93030; --down-bg:#fbeaea;
  --font:-apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.shell { display: flex; min-height: 100vh; }

/* Menu */
.side {
  position: fixed; inset: 0 auto 0 0; width: 232px; padding: 22px 14px; display: flex; flex-direction: column; gap: 6px; z-index: 30;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(255,255,255,.75), transparent 60%),
    radial-gradient(90% 50% at 100% 100%, rgba(232,180,30,.35), transparent 60%),
    linear-gradient(165deg, #fff3ac, #ffe163);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 16px; }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 10px; background: transparent; text-align: left; font-size: 15px; }
.nav-item:hover { background: rgba(255,255,255,.4); }
.nav-item.active { background: rgba(255,255,255,.7); color: var(--accent); font-weight: 600; }
.nav-sep { height: 1px; background: rgba(0,0,0,.09); margin: 10px 8px; }
.nav-glyph { width: 28px; text-align: center; font-size: 17px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.add-owner { margin-top: 8px; padding: 9px 10px; border: 1px dashed rgba(0,0,0,.25); border-radius: 10px; background: transparent; text-align: left; color: var(--ink-2); }
.add-owner:hover { background: rgba(255,255,255,.4); }

/* Contenu */
.main { margin-left: 232px; flex: 1; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 22px 40px 6px; max-width: 1040px; }
.top h1 { margin: 0; font-size: 22px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.status button { border: 1px solid var(--hairline); background: var(--panel); border-radius: 8px; width: 30px; height: 30px; color: var(--ink-2); }
.status button:hover { background: var(--hover); }
.status .warn { color: var(--down); }
.burger { display: none; border: 1px solid var(--hairline); background: var(--panel); border-radius: 8px; width: 36px; height: 36px; font-size: 18px; }
.view { padding: 8px 40px 80px; max-width: 1040px; }

section { margin-top: 44px; }
section:first-child { margin-top: 20px; }
h2 { margin: 0 0 14px; font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); }
.num { font-variant-numeric: tabular-nums; }

/* Hero */
.hero-label { color: var(--ink-2); font-size: 13px; margin-bottom: 2px; }
.hero-value { font-size: 40px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { padding: 5px 11px; border-radius: 999px; background: var(--panel); border: 1px solid var(--hairline); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chip.up { background: var(--up-bg); border-color: transparent; color: var(--up); }
.chip.down { background: var(--down-bg); border-color: transparent; color: var(--down); }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 36px; flex-wrap: wrap; }
.donut { position: relative; width: 200px; height: 200px; flex: none; }
.donut svg { width: 100%; height: 100%; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center b { font-size: 18px; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: 12px; color: var(--muted); }
.legend { flex: 1; min-width: 260px; display: flex; flex-direction: column; }
.leg-row { display: grid; grid-template-columns: 12px 1fr auto auto; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--hairline); font-variant-numeric: tabular-nums; }
.leg-row:last-child { border-bottom: 0; }
.dot { width: 12px; height: 12px; border-radius: 4px; }
.leg-sym { font-weight: 600; }
.leg-sub { color: var(--muted); font-size: 12px; margin-left: 8px; }

/* Listes / tableaux */
.rows { background: var(--panel); border: 1px solid var(--hairline); border-radius: 14px; overflow: hidden; }
.owner-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--hairline); background: transparent; text-align: left; }
.owner-row:last-child { border-bottom: 0; }
.owner-row:hover { background: var(--hover); }
.owner-row .grow { flex: 1; min-width: 0; }
.owner-row .sub { color: var(--muted); font-size: 13px; }
.owner-row .right { text-align: right; font-variant-numeric: tabular-nums; }
.tscroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--hairline); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: right; font-weight: 500; font-size: 12px; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
td { text-align: right; padding: 12px 14px; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
th:first-child, td:first-child { text-align: left; }
.coin { display: flex; align-items: center; gap: 10px; }
.badge { width: 32px; height: 32px; border-radius: 10px; color: #fff; display: grid; place-items: center; font-size: 10px; font-weight: 700; flex: none; }
.coin b { display: block; line-height: 1.2; }
.coin small { color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.pill.sell { background: var(--down-bg); color: var(--down); }
.pill.buy { background: var(--hover); color: var(--ink-2); }
.link { border: 0; background: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: 13px; }
.link:hover { color: var(--down); }
details summary { cursor: pointer; font-size: 18px; font-weight: 700; padding: 4px 0 14px; }
details[open] summary { margin-bottom: 0; }
.empty { background: var(--panel); border: 1px dashed var(--hairline); border-radius: 14px; padding: 28px; color: var(--ink-2); text-align: center; }

/* Boutons */
.btn { border: 1px solid var(--hairline); background: var(--panel); border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 14px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--down); }
.danger-zone { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--hairline); }

/* Formulaire d'achat (panneau déplié, jamais modal) */
.form-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .2s ease-out; }
.form-panel.open { grid-template-rows: 1fr; }
.form-inner { overflow: hidden; }
.form { margin-bottom: 16px; background: var(--panel); border: 1px solid var(--hairline); border-radius: 14px; padding: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); }
.form input, .form select { padding: 9px 11px; border: 1px solid var(--hairline); border-radius: 9px; background: #fff; font-size: 15px; width: 100%; }
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.form .full { grid-column: 1 / -1; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-total { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.form-err { color: var(--down); font-size: 13px; min-height: 18px; }

/* Récap */
.recap-block { margin-top: 36px; }
.recap-head { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; background: none; padding: 0 0 12px; text-align: left; }
.recap-head b { font-size: 18px; flex: 1; }
.recap-head .tot { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.recap-block .chips { margin: 0 0 12px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s ease-out, transform .2s ease-out; z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes flash-up { from { background: var(--up-bg); } to { background: transparent; } }
@keyframes flash-down { from { background: var(--down-bg); } to { background: transparent; } }
.flash-up { animation: flash-up 1.2s ease-out; border-radius: 6px; }
.flash-down { animation: flash-down 1.2s ease-out; border-radius: 6px; }

.scrim { display: none; }

@media (max-width: 720px) {
  .side { transform: translateX(-100%); transition: transform .2s ease-out; width: 260px; }
  .side.open { transform: none; box-shadow: 8px 0 30px rgba(0,0,0,.15); }
  .main { margin-left: 0; }
  .burger { display: block; }
  .top { padding: 14px 16px 4px; gap: 10px; flex-wrap: wrap; }
  .top h1 { font-size: 20px; }
  .status { width: 100%; justify-content: space-between; order: 3; }
  .view { padding: 4px 16px 80px; }
  .hero-value { font-size: 34px; }
  .form { grid-template-columns: 1fr 1fr; padding: 14px; }
  .donut-wrap { flex-direction: column; align-items: center; gap: 16px; }
  .legend { min-width: 0; width: 100%; flex: none; }
  .leg-row { grid-template-columns: 12px 1fr auto; }
  .leg-row .leg-pct { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.owner-row .sub.up, .rows .sub.up { color: var(--up); }
.owner-row .sub.down, .rows .sub.down { color: var(--down); }

.h2-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.add-owner[hidden], #faceBtn[hidden], #logoutBtn[hidden] { display: none; }
#login { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(120% 60% at 0% 0%, rgba(255,255,255,.75), transparent 60%), linear-gradient(165deg, #fff3ac, #ffe163); }
.login-card { background: var(--panel); border-radius: 18px; padding: 28px; width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 14px; box-shadow: 0 10px 40px rgba(0,0,0,.12); }
.login-card h2 { margin: 0; }
.login-card input { width: 100%; padding: 11px 13px; border: 1px solid var(--hairline); border-radius: 10px; font-size: 16px; }
.login-card .btn { width: 100%; padding: 11px; }

.h2-sub { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.h2-sub.up { color: var(--up); } .h2-sub.down { color: var(--down); }
