/* ==========================================================================
   Patrimoine PWA — Dark premium theme (Finary-inspired)
   ========================================================================== */
:root {
  --bg: #0B0E14;
  --bg-elev: #10141C;
  --card: #151A23;
  --card-2: #1B212C;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.11);
  --text: #ECEEF2;
  --text-2: #A3ABBA;
  --muted: #6B7385;
  --gold: #D4AF37;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --blue: #3B82F6;
  --blue-soft: rgba(59, 130, 246, 0.14);
  --green: #34D399;
  --green-soft: rgba(52, 211, 153, 0.13);
  --red: #F87171;
  --red-soft: rgba(248, 113, 113, 0.13);
  --violet: #A78BFA;

  --c-besoins: #3B82F6;
  --c-envies: #D4AF37;
  --c-epargne: #34D399;

  --radius: 20px;
  --radius-sm: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); overflow-x: hidden; max-width: 100vw; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  min-height: 100dvh;
  width: 100%;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { display: block; }
.hidden { display: none !important; }
.num, .amt { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--text-2); }
.gold { color: var(--gold); }

/* Privacy mode */
body.privacy .amt { filter: blur(9px); transition: filter .25s; }

/* ---------- Background glow ---------- */
#app::before {
  content: "";
  position: fixed; inset: 0 0 auto 0; height: 420px;
  background:
    radial-gradient(60% 60% at 15% 0%, rgba(59,130,246,0.13), transparent 70%),
    radial-gradient(50% 50% at 95% 5%, rgba(212,175,55,0.10), transparent 70%);
  pointer-events: none; z-index: 0;
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(var(--safe-top) + 14px) 20px 12px;
  background: linear-gradient(to bottom, rgba(11,14,20,0.92) 60%, rgba(11,14,20,0.0));
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
}
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.topbar h1 { margin: 2px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--border);
  transition: transform .15s var(--ease), background .2s;
}
.icon-btn:active { transform: scale(.92); background: var(--card-2); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--text-2); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
.badge-demo {
  font-size: 11px; font-weight: 700; color: var(--gold);
  background: var(--gold-soft); border: 1px solid rgba(212,175,55,.3);
  padding: 4px 8px; border-radius: 999px; letter-spacing: .04em; text-transform: uppercase;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Views ---------- */
main { position: relative; z-index: 1; }
.view {
  display: none;
  padding: 4px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 36px);
  animation: viewIn .35s var(--ease);
}
.view.active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  max-width: 100%;
}
.card.flush { padding: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.card-head > :first-child { flex: 1; min-width: 0; }
.card-title { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; line-height: 1.3; word-break: break-word; }
.card-title.lg { font-size: 16px; color: var(--text); font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
.card-head .row-sub { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.35; }
.section-label {
  font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em;
  margin: 20px 4px 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.section-label span:first-child { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-label .amt { color: var(--text-2); letter-spacing: 0; text-transform: none; font-size: 13px; flex: none; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.grid-2 .card { margin-bottom: 0; }
.kpi .label { font-size: 12px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 20px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.kpi .sub { font-size: 12px; margin-top: 4px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Hero ---------- */
.hero { padding: 6px 4px 6px; }
.hero .label { font-size: 13px; color: var(--text-2); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.hero .big { font-size: 42px; font-weight: 750; letter-spacing: -0.035em; line-height: 1.1; margin: 6px 0 8px; }
.hero .big .cents { font-size: 26px; color: var(--text-2); font-weight: 600; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  background: var(--card-2); color: var(--text-2);
}
.chip.pos { background: var(--green-soft); color: var(--green); }
.chip.neg { background: var(--red-soft); color: var(--red); }
.chip.gold { background: var(--gold-soft); color: var(--gold); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.hero-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }

/* ---------- Segmented controls & Search ---------- */
.search {
  display: flex; align-items: center; gap: 10px;
  width: 100%; background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-radius: 13px;
  padding: 10px 13px; margin-bottom: 12px;
}
.search svg { width: 17px; height: 17px; stroke: var(--muted); flex: none; }
.search input {
  flex: 1; min-width: 0; width: 100%; background: transparent;
  border: 0; outline: none; font-size: 15px; color: var(--text); padding: 0;
}
.search input::placeholder { color: var(--muted); font-size: 13.5px; }

.segmented {
  display: flex; width: 100%; max-width: 100%;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px; gap: 2px; position: relative;
  overflow: hidden;
}
.segmented button {
  flex: 1; min-width: 0; padding: 8px 6px; border-radius: 9px;
  font-size: 12px; font-weight: 650;
  color: var(--muted); transition: all .2s var(--ease);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
}
.segmented button.active { background: var(--card-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 4px 12px rgba(0,0,0,.25); }
.segmented.gold button.active { color: var(--gold); }
.pills { display: flex; gap: 4px; justify-content: space-between; margin-top: 10px; width: 100%; max-width: 100%; }
.pills button {
  flex: 1; min-width: 0; padding: 7px 6px; border-radius: 9px;
  font-size: 11.5px; font-weight: 700; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center; transition: all .2s;
}
.pills button.active { background: var(--blue-soft); color: var(--blue); }
.pills.gold button.active { background: var(--gold-soft); color: var(--gold); }
.scroll-x { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; }
.scroll-x::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--card); border: 1px solid var(--border); color: var(--text-2);
}
.filter-chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart svg { width: 100%; overflow: visible; }
.chart .axis-label { fill: var(--muted); font-size: 10px; font-weight: 500; }
.chart .grid-line { stroke: rgba(255,255,255,0.05); stroke-dasharray: 3 4; }
.chart-tooltip {
  position: absolute; top: 0; transform: translateX(-50%);
  background: var(--card-2); border: 1px solid var(--border-strong); border-radius: 10px;
  padding: 5px 9px; font-size: 11px; font-weight: 600; color: var(--text-2); pointer-events: none;
  white-space: nowrap; opacity: 0; transition: opacity .15s;
}
.chart-tooltip.show { opacity: 1; }
.chart-tooltip b { color: var(--text); font-size: 12px; display: block; }
.chart-empty { height: 160px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { width: 150px; height: 150px; flex: none; position: relative; }
.donut svg path { transition: opacity .2s, transform .25s var(--ease); transform-origin: 50% 50%; cursor: pointer; }
.donut svg.has-focus path:not(.focus) { opacity: .25; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
.donut-center .t { font-size: 11px; color: var(--muted); font-weight: 600; max-width: 90px; }
.donut-center .v { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.legend { flex: 1; display: flex; flex-direction: column; gap: 9px; min-width: 0; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-item .name { flex: 1; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-item .pct { font-weight: 650; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--border); transition: background .15s;
}
.row:last-child { border-bottom: 0; }
.row.tap:active { background: rgba(255,255,255,0.03); }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 750; font-size: 13px; letter-spacing: -0.02em;
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-right { text-align: right; flex: none; }
.row-value { font-weight: 650; font-size: 15px; }
.row-delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.chev { width: 14px; height: 14px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }

/* Crowdfunding cards */
.cf-card { padding: 16px; border-bottom: 1px solid var(--border); }
.cf-card:last-child { border-bottom: 0; }
.cf-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.cf-meta { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.progress { height: 6px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--blue), #60A5FA); transition: width .8s var(--ease); }
.progress.gold > span { background: linear-gradient(90deg, #B8912A, var(--gold)); }
.progress-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ---------- Budget gauges ---------- */
.gauge { margin-bottom: 18px; }
.gauge:last-child { margin-bottom: 0; }
.gauge-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.gauge-name { font-weight: 650; display: flex; align-items: center; gap: 8px; }
.gauge-name small { color: var(--muted); font-weight: 600; font-size: 12px; }
.gauge-val { font-size: 13px; color: var(--text-2); }
.gauge-val b { color: var(--text); font-weight: 650; }
.gauge-track { position: relative; height: 10px; border-radius: 99px; background: rgba(255,255,255,0.06); overflow: visible; }
.gauge-fill { height: 100%; border-radius: 99px; transition: width 1s var(--ease); max-width: 100%; }
.gauge-over { position: absolute; top: 0; height: 100%; border-radius: 0 99px 99px 0; background: repeating-linear-gradient(45deg, var(--red), var(--red) 4px, #c45252 4px, #c45252 8px); }
.gauge-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }

.ring-wrap { display: flex; align-items: center; gap: 18px; }
.ring { width: 118px; height: 118px; position: relative; flex: none; }
.ring svg circle { transition: stroke-dashoffset 1.1s var(--ease); }
.ring-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-center .v { font-size: 22px; font-weight: 750; letter-spacing: -0.03em; }
.ring-center .t { font-size: 11px; color: var(--muted); font-weight: 600; }
.ring-stats { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.ring-stats .line { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); }
.ring-stats .line b { color: var(--text); font-weight: 650; }

.tx-day { font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 16px 4px; text-transform: capitalize; }
.cat-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 17px; flex: none; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; letter-spacing: .02em; }
.input, select.input, textarea.input {
  width: 100%; background: var(--bg-elev); border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 13px 14px; font-size: 16px; outline: none; transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none; appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7385' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px;
}
.input:focus { border-color: rgba(59,130,246,.6); box-shadow: 0 0 0 4px rgba(59,130,246,.12); }
.input::placeholder { color: var(--muted); }
.amount-input {
  width: 100%; background: transparent; border: 0; outline: none; text-align: center;
  font-size: 52px; font-weight: 750; letter-spacing: -0.04em; padding: 4px 0; caret-color: var(--gold);
}
.amount-wrap { text-align: center; padding: 6px 0 14px; position: relative; }
.amount-wrap .cur { font-size: 28px; color: var(--muted); font-weight: 700; margin-left: 4px; }
.amount-row { display: flex; align-items: baseline; justify-content: center; }
.amount-row input { width: auto; max-width: 75%; }
.cat-auto {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-elev); border: 1px dashed var(--border-strong); font-size: 15px;
}
.cat-auto .tag { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.cat-auto small { color: var(--muted); font-size: 11px; }
.sub-grid { display: flex; flex-wrap: wrap; gap: 8px; max-height: 172px; overflow-y: auto; padding: 2px; }
.sub-chip {
  padding: 9px 12px; border-radius: 11px; font-size: 13px; font-weight: 600;
  background: var(--bg-elev); border: 1px solid var(--border-strong); color: var(--text-2);
  transition: all .15s;
}
.sub-chip.active { color: var(--bg); border-color: transparent; }
.row-inline { display: flex; gap: 10px; }
.row-inline > * { flex: 1; }

.btn {
  width: 100%; padding: 16px; border-radius: 15px; font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s var(--ease), opacity .2s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn-gold { background: linear-gradient(135deg, #F0D67A, var(--gold) 45%, #A9832A); color: #1A1404; box-shadow: 0 10px 30px -10px rgba(212,175,55,.55); }
.btn-blue { background: linear-gradient(135deg, #60A5FA, var(--blue)); color: white; box-shadow: 0 10px 30px -10px rgba(59,130,246,.6); }
.btn-ghost { background: var(--card-2); color: var(--text); border: 1px solid var(--border-strong); }
.btn-sm { padding: 10px 14px; font-size: 14px; border-radius: 12px; width: auto; }
.btn .spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

.toggle { position: relative; width: 50px; height: 30px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: rgba(255,255,255,.1); border-radius: 99px; transition: .25s; }
.toggle span::after { content: ""; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; background: white; border-radius: 50%; transition: .25s var(--ease); box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(20px); }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; }
.setting-row .t { font-weight: 600; font-size: 14px; }
.setting-row .d { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Range slider */
.slider-field { margin-bottom: 16px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.slider-head b { color: var(--text); font-size: 15px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; background: rgba(255,255,255,.08); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.4), 0 0 0 5px rgba(212,175,55,.25); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 0; }

/* ---------- AI ---------- */
.ai-hero {
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(59,130,246,.18), transparent 60%),
    radial-gradient(100% 100% at 100% 100%, rgba(212,175,55,.14), transparent 60%),
    var(--card);
}
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.ai-chip {
  padding: 10px 13px; border-radius: 12px; font-size: 13px; font-weight: 600; text-align: left;
  background: rgba(255,255,255,.04); border: 1px solid var(--border-strong); color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.ai-chip:active { background: rgba(255,255,255,.08); }
.ai-output { font-size: 14.5px; line-height: 1.6; color: #D9DDE5; }
.ai-output h1, .ai-output h2, .ai-output h3 { font-size: 16px; margin: 18px 0 6px; color: var(--text); letter-spacing: -0.01em; }
.ai-output h1:first-child, .ai-output h2:first-child, .ai-output h3:first-child { margin-top: 0; }
.ai-output strong { color: var(--text); }
.ai-output ul, .ai-output ol { padding-left: 20px; margin: 6px 0; }
.ai-output li { margin: 4px 0; }
.ai-output p { margin: 8px 0; }
.ai-output code { background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.ai-output table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 8px 0; }
.ai-output td, .ai-output th { border: 1px solid var(--border-strong); padding: 6px; text-align: left; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: 1; transform: none; } }
.key-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.legend-inline { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 8px var(--safe-bottom);
  background: rgba(16, 20, 28, 0.82);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--border);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 10.5px; font-weight: 600; padding: 8px 0; transition: color .2s; }
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--ease); }
.tab.active { color: var(--text); }
.tab.active svg { stroke: var(--gold); transform: translateY(-1px); }
.tab:active svg { transform: scale(.88); }
.tab-fab-slot { display: grid; place-items: center; }
.fab {
  width: 58px; height: 58px; border-radius: 20px; margin-top: -26px;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #F3D77A 0%, var(--gold) 45%, #A07A22 100%);
  box-shadow: 0 12px 28px -6px rgba(212,175,55,.55), 0 0 0 6px var(--bg), inset 0 1px 0 rgba(255,255,255,.4);
  transition: transform .2s var(--ease);
}
.fab svg { width: 26px; height: 26px; stroke: #1A1404; stroke-width: 2.6; stroke-linecap: round; fill: none; transition: transform .3s var(--ease); }
.fab:active { transform: scale(.9); }
.fab.open svg { transform: rotate(45deg); }

/* ---------- Bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity .3s;
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.sheet-backdrop.show { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  width: 100%; max-width: 100vw; overflow-x: hidden;
  max-height: calc(100dvh - var(--safe-top) - 24px);
  background: #121722; border-top: 1px solid var(--border-strong);
  border-radius: 26px 26px 0 0;
  transform: translateY(105%); transition: transform .42s var(--ease);
  display: flex; flex-direction: column;
  box-shadow: 0 -20px 60px rgba(0,0,0,.5);
}
.sheet.show { transform: translateY(0); }
.sheet.dragging { transition: none; }
.sheet-grabber { width: 40px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.18); margin: 10px auto 4px; flex: none; }
.sheet-content { overflow-y: auto; overflow-x: hidden; width: 100%; max-width: 100%; padding: 8px 16px calc(var(--safe-bottom) + 24px); -webkit-overflow-scrolling: touch; }
.sheet-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin: 4px 0 4px; line-height: 1.25; word-break: break-word; }
.sheet-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; line-height: 1.35; word-break: break-word; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; width: 100%; }
.detail-grid .cell { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; overflow: hidden; }
.detail-grid .cell .k { font-size: 11px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-grid .cell .v { font-size: 15px; font-weight: 650; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; color: var(--muted); background: rgba(255,255,255,.05); padding: 2px 6px; border-radius: 6px; margin-left: 6px; }
pre.diag { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px; padding: 12px; font-size: 11px; overflow: auto; max-height: 260px; color: var(--text-2); white-space: pre-wrap; word-break: break-all; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; z-index: 60;
  top: calc(var(--safe-top) + 12px);
  transform: translate(-50%, -150%);
  background: rgba(27, 33, 44, .96); border: 1px solid var(--border-strong);
  padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; max-width: calc(100% - 32px);
  box-shadow: 0 10px 40px rgba(0,0,0,.45);
  transition: transform .4s var(--ease);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.toast.show { transform: translate(-50%, 0); }
.toast.ok::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex: none; }
.toast.err::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }

/* ---------- Pull to refresh ---------- */
.ptr { position: fixed; top: calc(var(--safe-top) + 70px); left: 50%; transform: translate(-50%, -60px); z-index: 15; opacity: 0; transition: opacity .2s; }
.ptr-spinner { width: 28px; height: 28px; border-radius: 50%; border: 2.5px solid var(--gold); border-right-color: transparent; }
.ptr.loading .ptr-spinner { animation: spin .7s linear infinite; }

/* ---------- Splash / skeleton ---------- */
.splash { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-content: center; justify-items: center; gap: 26px; transition: opacity .5s, visibility .5s; }
.splash.hide { opacity: 0; visibility: hidden; }
.splash-logo { width: 84px; height: 84px; border-radius: 24px; background: var(--card); border: 1px solid var(--border-strong); display: grid; place-items: center; box-shadow: 0 20px 60px -10px rgba(212,175,55,.25); }
.splash-logo svg { width: 48px; height: 48px; }
.splash-bar { width: 120px; height: 3px; background: rgba(255,255,255,.07); border-radius: 99px; overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 40%; background: var(--gold); border-radius: 99px; animation: load 1.1s ease-in-out infinite; }
@keyframes load { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.skeleton { background: linear-gradient(90deg, rgba(255,255,255,.04), rgba(255,255,255,.08), rgba(255,255,255,.04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 10px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.footnote { text-align: center; font-size: 11px; color: var(--muted); margin-top: 18px; }
.offline-banner { background: var(--gold-soft); color: var(--gold); border: 1px solid rgba(212,175,55,.25); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; font-weight: 600; margin-bottom: 14px; }

/* ---------- News & Live Alerts (Style TradingView) ---------- */
.live-pulse {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #EF4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse-red 2s infinite;
  vertical-align: middle;
  flex: none;
}
@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.chip-news-alert {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.12);
  color: #EF4444;
  border: 1px solid rgba(239, 68, 68, 0.25);
  letter-spacing: 0.02em;
}

.news-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: all 0.15s ease;
  display: block;
  text-decoration: none;
}
.news-card:hover, .news-card:active {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(96, 165, 250, 0.5);
  transform: translateY(-1px);
}
.news-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.news-source {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}
.news-time {
  font-size: 10.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
}
.news-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

@media (min-width: 640px) {
  .view, .topbar { max-width: 560px; margin-left: auto; margin-right: auto; }
  .sheet { max-width: 560px; margin: 0 auto; }
  .tabbar { max-width: 560px; margin: 0 auto; border-radius: 22px 22px 0 0; border: 1px solid var(--border); }
}
