:root {
  color-scheme: dark;
  --bg: #101312;
  --panel: #171b1a;
  --panel-soft: #1e2422;
  --surface: #121615;
  --line: #2e3935;
  --text: #f2f5f1;
  --muted: #9ba8a2;
  --accent: #ffff00;
  --accent-2: #abff00;
  --danger: #ff6b6b;
  --warning: #ffc857;
  --shadow: 0 18px 45px rgba(0, 0, 0, .28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-light {
  color-scheme: light;
  --bg: #eef3ee;
  --panel: #ffffff;
  --panel-soft: #e8efe9;
  --surface: #f7faf6;
  --line: #cbd8cf;
  --text: #111914;
  --muted: #64736b;
  --accent: #d7d900;
  --accent-2: #6fb300;
  --danger: #cf3f3f;
  --warning: #b97c00;
  --shadow: 0 14px 34px rgba(30, 44, 36, .13);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

body.alert-active {
  animation: alertPulse 1.2s ease-in-out infinite alternate;
}

@keyframes alertPulse {
  from { background: var(--bg); }
  to { background: linear-gradient(135deg, #101312 0%, rgba(255, 255, 0, .28) 52%, rgba(171, 255, 0, .22) 100%); }
}

button,
input,
select {
  font: inherit;
}

button,
select {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 8px;
}

button {
  cursor: pointer;
  padding: 10px 14px;
}

button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: default;
  opacity: .58;
}

[data-tip] {
  cursor: help;
  position: relative;
}

[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 80;
  width: min(280px, 80vw);
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-transform: none;
  letter-spacing: 0;
  white-space: normal;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1211;
  color: var(--text);
  padding: 10px 11px;
}

body.theme-light input,
body.theme-light select {
  background: #ffffff;
}

body.theme-light .portfolio-name-input {
  background: transparent;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 14px;
}

.app-shell {
  width: min(1640px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar,
.summary-band,
.workspace,
.panel-head,
.asset-row,
.asset-main,
.topbar-actions,
.chart-controls,
.alert-row,
.bar-row {
  display: flex;
}

.topbar {
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.title-area {
  min-width: 280px;
}

.portfolio-title-line {
  display: flex;
  align-items: center;
  gap: 12px;
}

.portfolio-name-input {
  width: min(520px, 70vw);
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
  font-weight: 800;
}

.portfolio-name-input:focus {
  outline: 1px solid var(--accent);
  outline-offset: 6px;
  border-radius: 4px;
}

.platform-logo {
  width: auto;
  min-width: 58px;
  height: 58px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.05;
  padding: 0 8px;
  text-align: center;
}

.platform-logo img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-line img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.brand-line em {
  color: var(--accent-2);
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
}

.app-version {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: none;
}

.indicator-controls {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  max-width: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.indicator-controls legend {
  width: auto;
  margin: 0 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  white-space: nowrap;
}

.indicator-controls label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.indicator-controls input {
  width: 13px;
  height: 13px;
  padding: 0;
  accent-color: var(--accent);
}

.document-status,
.subtle-line,
.asset-subtitle,
.asset-price,
.asset-profit,
#selectedMeta,
#tradingMeta {
  color: var(--muted);
}

.document-status {
  display: block;
  margin-top: 8px;
}

.topbar-actions {
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.theme-toggle {
  width: 48px;
  height: 34px;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 0;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}

.theme-toggle span {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  border-radius: 999px;
}

.theme-toggle span:last-child,
.theme-toggle.is-light span:first-child {
  background: var(--accent);
  color: #07110d;
}

.theme-toggle.is-light span:last-child {
  background: transparent;
  color: var(--muted);
}

#portfolioSelect {
  width: 180px;
}

#openInput,
#historyInput {
  display: none;
}

.summary-band {
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.summary-band > div {
  flex: 1;
  min-width: 170px;
  padding: 18px;
  background: var(--panel);
}

.summary-band span {
  color: var(--muted);
}

.summary-band strong {
  display: block;
  margin-top: 8px;
  font-size: 23px;
}

.summary-band strong small {
  display: block;
  margin-top: 2px;
  font-size: 13px;
}

.range-controls {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.range-controls button {
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 11px;
}

.range-controls button.is-active {
  background: var(--accent);
  color: #07110d;
}

.workspace {
  align-items: flex-start;
  gap: 18px;
  margin-top: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.portfolio-panel {
  width: min(520px, 100%);
  padding: 18px;
  position: sticky;
  top: 16px;
}

.main-column {
  display: grid;
  flex: 1;
  min-width: 0;
  gap: 18px;
}

.insight-panel,
.alerts-panel,
.chart-panel,
.stablecoin-panel,
.fear-greed-panel {
  padding: 18px;
}

.panel-head {
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.selected-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

.selected-heading img {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  object-fit: contain;
}

.selected-heading h2 {
  margin: 0;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
}

.operation-form,
.alert-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.operation-form {
  grid-template-columns: 1fr 1fr;
  margin: 16px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.alert-form {
  grid-template-columns: 1fr 1.2fr 1fr auto;
  align-items: end;
}

.operation-form label,
.alert-form label,
.chart-controls label,
.currency-tools label,
.inline-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.form-title,
.operation-form button {
  grid-column: 1 / -1;
}

.operation-form button,
.alert-form button {
  background: var(--accent);
  color: #07110d;
  border-color: var(--accent);
  font-weight: 700;
}

.asset-list,
.alert-list,
.allocation-chart,
.compare-chart {
  display: grid;
  gap: 8px;
}

.cash-card {
  display: grid;
  margin-bottom: 10px;
  width: 100%;
  max-width: 100%;
  grid-template-columns: minmax(116px, 1fr) minmax(112px, 138px) 74px 74px 30px !important;
  align-self: stretch;
}

.cash-card .correction-fields {
  grid-template-columns: 1fr;
}

.cash-card .edit-button {
  grid-column: 3 / 4;
  width: 74px;
}

.cash-grid-spacer {
  grid-column: 4 / 5;
  width: 74px;
  height: 30px;
}

.cash-card .remove-button {
  grid-column: 5 / 6;
  justify-self: end;
  align-self: center;
}

.portfolio-panel > .asset-row,
.asset-list > .asset-row {
  width: 100%;
}

.asset-row {
  display: grid;
  grid-template-columns: minmax(116px, 1fr) minmax(112px, 138px) 74px 74px 30px;
  align-items: center;
  gap: 8px;
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.asset-row.is-selected {
  border-color: var(--accent);
  background: #24240f;
}

body.theme-light .asset-row.is-selected {
  background: #fbfbd5;
}

.asset-row.is-staking {
  border-color: rgba(171, 255, 0, .55);
}

.asset-row.is-selected.is-staking {
  border-color: var(--accent-2);
  background: #1b2a10;
}

body.theme-light .asset-row.is-selected.is-staking {
  background: #e9ffd8;
}

.asset-main {
  align-items: center;
  min-width: 0;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}

.asset-main span:last-child {
  min-width: 0;
}

.asset-title,
.asset-subtitle {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-rank {
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 700;
}

.staking-badge {
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 900;
}

.coin-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.coin-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.asset-numbers {
  min-width: 0;
  width: 138px;
  text-align: right;
}

.asset-numbers strong {
  font-size: 15px;
}

.asset-numbers small {
  font-size: 11px;
  line-height: 1.25;
}

.asset-numbers strong,
.asset-numbers small {
  display: block;
}

.inline-field {
  width: 100%;
  min-width: 0;
  gap: 3px;
  font-size: 11px;
}

.inline-field input {
  height: 32px;
  padding: 6px 7px;
}

.edit-button {
  width: 74px;
  height: 30px;
  padding: 0;
  font-size: 11px;
}

.stake-button {
  width: 74px;
  height: 30px;
  padding: 0;
  border-color: rgba(171, 255, 0, .42);
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 800;
}

.stake-button[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}

.asset-row.is-staking .stake-button {
  background: var(--accent-2);
  color: #07110d;
}

.correction-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.remove-button {
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--danger);
}

.asset-row .remove-button {
  grid-column: 5 / 6;
  grid-row: 1;
}

.chart-controls {
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chart-controls select,
.currency-tools select,
.timeframe-control select {
  width: 118px;
}

.currency-tools {
  display: flex;
  align-items: end;
  gap: 8px;
}

.currency-tools small {
  display: none;
}

#setDefaultCurrencyBtn {
  min-width: 158px;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(170px, .7fr) minmax(360px, 1.4fr) minmax(190px, .9fr);
  gap: 10px;
}

.metric-card {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-card span,
.mini-chart-head small {
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
}

.metric-subvalue {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.timeframe-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  min-width: 118px;
}

.metric-card strong small {
  display: block;
  margin-top: 2px;
  font-size: 13px;
}

.compare-metric {
  min-height: 116px;
}

.allocation-panel {
  margin-top: 16px;
}

.mini-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.compare-chart,
.allocation-chart {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.compare-chart {
  margin-top: 10px;
  border: 0;
  padding: 0;
  background: transparent;
}

.pie-chart {
  width: min(300px, 34vw);
  aspect-ratio: 1;
  margin: 20px auto;
  border-radius: 50%;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 38px #0f1211;
  position: relative;
  z-index: 2;
}

body.theme-light .pie-chart {
  box-shadow: inset 0 0 0 38px #ffffff;
}

.pie-wrap {
  position: relative;
  min-height: 520px;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.pie-callout {
  position: absolute;
  min-width: 118px;
  max-width: 152px;
  padding: 8px 10px;
  border-left: 3px solid;
  border-radius: 6px;
  background: #0f1211;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .22);
  z-index: 4;
  transform: var(--callout-transform, translate(-50%, -50%)) translateZ(0);
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform;
  transition: transform .16s ease, box-shadow .16s ease;
}

.pie-callout:hover {
  z-index: 30 !important;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .36);
  transform: var(--callout-transform, translate(-50%, -50%)) translateZ(0) scale(1.14);
}

body.theme-light .pie-callout {
  background: #ffffff;
}

.pie-callout strong,
.pie-callout span,
.pie-callout small {
  display: block;
}

.pie-callout strong {
  font-size: 14px;
}

.pie-callout span {
  font-weight: 800;
}

.pie-callout small {
  color: var(--muted);
  font-size: 12px;
}

.pie-label,
.pie-share,
.pie-value {
  display: block;
}

.pie-label {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.pie-share {
  font-size: 12px;
  font-weight: 800;
}

.pie-value {
  color: var(--muted);
  font-size: 11px;
}

.bar-row {
  align-items: center;
  gap: 10px;
}

.bar-label {
  width: 108px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.bar-track {
  flex: 1;
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #0f1211;
}

body.theme-light .bar-track {
  background: #dde7df;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.bar-fill.is-loss {
  background: linear-gradient(90deg, #ff6b6b, #ffc857);
}

.bar-value {
  width: 120px;
  text-align: right;
  font-size: 13px;
  font-weight: 800;
}

.alert-row {
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.alert-row.is-triggered {
  border-color: var(--accent);
  background: #252510;
}

body.theme-light .alert-row.is-triggered {
  background: #ffffcf;
}

.alert-row strong,
.alert-row small {
  display: block;
}

.app-dialog {
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, .72);
}

.app-dialog form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.app-dialog menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.platform-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.platform-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
}

.platform-choice img {
  width: 24px;
  height: 24px;
}

.custom-platform-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
}

.custom-platform-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.trading-view {
  width: 100%;
  height: min(62vh, 640px);
  min-height: 460px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f1211;
}

body.theme-light .trading-view {
  background: #ffffff;
}

.bitcoin-cycle-strip {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.cycle-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.cycle-strip-title {
  display: block;
  font-weight: 900;
}

.cycle-strip-warning {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.cycle-phase-badge {
  min-width: 190px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 200, 87, .48);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255, 200, 87, .14), rgba(255, 107, 107, .10));
  text-align: right;
}

.cycle-phase-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.cycle-phase-value {
  display: block;
  margin-top: 4px;
  color: var(--warning);
  font-size: 18px;
  font-weight: 950;
}

.cycle-strip-track {
  position: relative;
  display: flex;
  min-height: 38px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cycle-strip-segment {
  display: grid;
  place-items: center;
  padding: 0 8px;
  color: #111914;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.cycle-segment-detail {
  font-size: 10px;
  font-weight: 800;
  opacity: .74;
}

.cycle-strip-segment.is-accumulation {
  background: #85d7ff;
}

.cycle-strip-segment.is-expansion {
  background: #abff00;
}

.cycle-strip-segment.is-mature {
  background: #ffff00;
}

.cycle-strip-segment.is-distribution {
  background: #ffc857;
}

.cycle-strip-segment.is-reset {
  background: #ff8c8c;
}

.cycle-strip-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  border-radius: 999px;
  background: var(--text);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .22);
}

.cycle-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.cycle-stat-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.cycle-stat-label,
.cycle-stat-note {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.cycle-stat-value {
  display: block;
  margin: 5px 0;
  font-size: 14px;
  font-weight: 900;
}

.cycle-history {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.cycle-history-row {
  display: grid;
  grid-template-columns: minmax(92px, .6fr) minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.cycle-history-cycle {
  color: var(--text);
  font-weight: 900;
}

.stablecoin-flow-chart {
  position: relative;
  width: 100%;
  height: 190px;
  display: flex;
  align-items: stretch;
  gap: 5px;
  padding: 24px 18px 30px 48px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(to bottom, transparent calc(50% - 1px), var(--line) calc(50% - 1px), var(--line) calc(50% + 1px), transparent calc(50% + 1px)),
    var(--surface);
}

.stablecoin-axis-label,
.stablecoin-zero-label,
.stablecoin-scale-label {
  position: absolute;
  z-index: 2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}

.stablecoin-axis-label.is-y {
  left: 9px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
}

.stablecoin-axis-label.is-x {
  left: 50%;
  bottom: 7px;
  transform: translateX(-50%);
}

.stablecoin-zero-label {
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
}

.stablecoin-scale-label {
  left: 28px;
}

.stablecoin-scale-label.is-top {
  top: 10px;
}

.stablecoin-scale-label.is-bottom {
  bottom: 22px;
}

.stablecoin-bar {
  width: 100%;
  min-height: 5px;
  border-radius: 4px 4px 0 0;
  cursor: help;
}

.stablecoin-bar-slot {
  flex: 1 1 0;
  min-width: 5px;
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 0;
}

.stablecoin-half {
  display: flex;
}

.stablecoin-half.is-upper {
  align-items: flex-end;
}

.stablecoin-half.is-lower {
  align-items: flex-start;
}

.stablecoin-bar.is-inflow {
  background: linear-gradient(180deg, var(--accent-2), rgba(171, 255, 0, .42));
}

.stablecoin-bar.is-outflow {
  border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, rgba(255, 107, 107, .42), var(--danger));
}

.stablecoin-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.stablecoin-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.stablecoin-legend i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
}

.legend-in {
  background: var(--accent-2);
}

.legend-out {
  background: var(--danger);
}

.stablecoin-range-controls {
  justify-content: flex-end;
}

.stablecoin-tooltip {
  position: absolute;
  z-index: 20;
  display: grid;
  gap: 4px;
  min-width: 178px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 12px;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 10px));
}

.stablecoin-tooltip span {
  color: var(--muted);
}

.stablecoin-panel {
  position: relative;
}

.stablecoin-panel .panel-head {
  align-items: flex-start;
}

.empty-state,
.status-line {
  padding: 18px;
  color: var(--muted);
}

.change-positive {
  color: var(--accent-2);
}

.change-negative {
  color: var(--danger);
}

.change-neutral {
  color: var(--muted);
}

@media print {
  body {
    background: #fff;
    color: #111;
  }

  .topbar-actions,
  .operation-form,
  .alerts-panel,
  .chart-panel,
  .remove-button,
  .inline-field {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .workspace,
  .summary-band,
  .allocation-panel,
  .insight-grid {
    display: block;
  }

  .panel,
  .summary-band,
  .summary-band > div,
  .asset-row,
  .metric-card,
  .compare-chart,
  .allocation-chart {
    background: #fff;
    color: #111;
    box-shadow: none;
    border-color: #ccc;
  }

  .portfolio-panel {
    position: static;
    width: 100%;
  }
}

@media (max-width: 1120px) {
  .workspace,
  .topbar,
  .summary-band {
    flex-direction: column;
  }

  .portfolio-panel {
    position: static;
    width: 100%;
  }

  .summary-band > div {
    width: 100%;
  }
}

@media (max-width: 820px) {
  .insight-grid,
  .alert-form {
    grid-template-columns: 1fr;
  }

  .chart-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .indicator-controls {
    flex-wrap: wrap;
    justify-content: flex-start;
    max-width: none;
  }

  .stablecoin-range-controls {
    justify-content: flex-start;
  }

  .indicator-controls legend {
    width: 100%;
    text-align: left;
  }

  .cycle-strip-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .cycle-phase-badge {
    width: 100%;
    text-align: left;
  }

  .cycle-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cycle-history-row {
    grid-template-columns: 1fr;
  }

  .cycle-strip-warning {
    text-align: left;
  }

  .cycle-strip-segment {
    font-size: 10px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 16px;
  }

  .operation-form {
    grid-template-columns: 1fr;
  }

  .cycle-stat-grid {
    grid-template-columns: 1fr;
  }

  .asset-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .asset-numbers,
  .inline-field {
    width: 100%;
    text-align: left;
  }

  .asset-numbers {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .asset-row .remove-button {
    grid-column: 4 / 5;
  }

  .correction-fields {
    grid-column: 1 / -1;
  }
}



/* ============================================
   SPLASH SCREEN - Animation de chargement
   ============================================ */

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0a0a15 70%, #000000 100%);
  overflow: hidden;
  animation: splashFadeOut 0.4s ease-in 1.2s forwards;
}

.splash-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
}

/* --- Anneaux orbitaux --- */
.splash-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  margin-top: -100px;
  margin-left: -100px;
  border: 2px solid transparent;
  border-top-color: #f7931a;
  border-right-color: rgba(247, 147, 26, 0.4);
  border-radius: 50%;
  animation: splashSpin 1s linear infinite;
  box-shadow: 0 0 20px rgba(247, 147, 26, 0.3);
}

.splash-ring-2 {
  width: 250px;
  height: 250px;
  margin-top: -125px;
  margin-left: -125px;
  border-top-color: #ffff00;
  border-right-color: rgba(255, 255, 0, 0.3);
  animation: splashSpinReverse 1.5s linear infinite;
  box-shadow: 0 0 15px rgba(255, 255, 0, 0.2);
}

.splash-ring-3 {
  width: 300px;
  height: 300px;
  margin-top: -150px;
  margin-left: -150px;
  border: 1px solid transparent;
  border-bottom-color: rgba(247, 147, 26, 0.5);
  border-left-color: rgba(255, 255, 0, 0.2);
  animation: splashSpin 2s linear infinite;
}

/* --- Particules flottantes --- */
.splash-particles {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
}

.splash-particles span {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f7931a;
  animation: splashParticle 1.2s ease-out infinite;
  opacity: 0;
}

.splash-particles span:nth-child(1)  { animation-delay: 0s;    transform: rotate(0deg)   translateY(-80px); }
.splash-particles span:nth-child(2)  { animation-delay: 0.1s;  transform: rotate(30deg)  translateY(-80px); background: #ffff00; }
.splash-particles span:nth-child(3)  { animation-delay: 0.2s;  transform: rotate(60deg)  translateY(-80px); }
.splash-particles span:nth-child(4)  { animation-delay: 0.3s;  transform: rotate(90deg)  translateY(-80px); background: #ffff00; }
.splash-particles span:nth-child(5)  { animation-delay: 0.4s;  transform: rotate(120deg) translateY(-80px); }
.splash-particles span:nth-child(6)  { animation-delay: 0.5s;  transform: rotate(150deg) translateY(-80px); background: #ffff00; }
.splash-particles span:nth-child(7)  { animation-delay: 0.6s;  transform: rotate(180deg) translateY(-80px); }
.splash-particles span:nth-child(8)  { animation-delay: 0.7s;  transform: rotate(210deg) translateY(-80px); background: #ffff00; }
.splash-particles span:nth-child(9)  { animation-delay: 0.8s;  transform: rotate(240deg) translateY(-80px); }
.splash-particles span:nth-child(10) { animation-delay: 0.9s;  transform: rotate(270deg) translateY(-80px); background: #ffff00; }
.splash-particles span:nth-child(11) { animation-delay: 1s;    transform: rotate(300deg) translateY(-80px); }
.splash-particles span:nth-child(12) { animation-delay: 1.1s;  transform: rotate(330deg) translateY(-80px); background: #ffff00; }

/* --- Logos --- */
.splash-logo-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  margin: auto;
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120px;
  height: 120px;
  margin-top: -60px;
  margin-left: -60px;
  object-fit: contain;
  border-radius: 50%;
  filter: drop-shadow(0 0 20px rgba(247, 147, 26, 0.8));
}

/* Logo Sitetechno : apparaît en premier, puis disparaît */
.splash-logo-sitetechno {
  animation: splashLogoSitetechno 1.2s ease-in-out forwards;
}

/* Logo Bitcoin : apparaît après transformation */
.splash-logo-bitcoin {
  opacity: 0;
  transform: scale(0) rotate(-180deg);
  animation: splashLogoBitcoin 1.2s ease-in-out forwards;
  filter: drop-shadow(0 0 25px rgba(247, 147, 26, 1));
}

/* --- Texte et barre de progression --- */
.splash-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 2;
  margin-top: 400px;
}

.splash-text-line {
  color: #ccc;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 2px;
  text-transform: uppercase;
  animation: splashTextPulse 0.6s ease-in-out infinite alternate;
}

.splash-progress {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.splash-progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #f7931a, #ffff00, #f7931a);
  border-radius: 2px;
  animation: splashProgressBar 1s ease-in-out forwards;
  box-shadow: 0 0 10px rgba(247, 147, 26, 0.8);
}

/* --- KEYFRAMES --- */

@keyframes splashSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes splashSpinReverse {
  from { transform: rotate(360deg); }
  to   { transform: rotate(0deg); }
}

@keyframes splashParticle {
  0% {
    opacity: 0;
    transform: rotate(var(--r, 0deg)) translateY(-40px) scale(0);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(var(--r, 0deg)) translateY(-120px) scale(1.5);
  }
}

/* Logo Sitetechno : scale up, pulse, puis disparaît en flash */
@keyframes splashLogoSitetechno {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(-90deg);
    filter: drop-shadow(0 0 0px rgba(255, 255, 0, 0));
  }
  15% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    filter: drop-shadow(0 0 20px rgba(255, 255, 0, 0.8));
  }
  30% {
    transform: scale(1.1) rotate(0deg);
    filter: drop-shadow(0 0 30px rgba(255, 255, 0, 1));
  }
  45% {
    transform: scale(1) rotate(5deg);
    filter: drop-shadow(0 0 20px rgba(255, 255, 0, 0.8));
  }
  55% {
    transform: scale(1.05) rotate(-3deg);
    filter: drop-shadow(0 0 25px rgba(247, 147, 26, 0.9));
  }
  65% {
    opacity: 1;
    transform: scale(0.9) rotate(10deg);
    filter: drop-shadow(0 0 40px rgba(247, 147, 26, 1));
  }
  75% {
    opacity: 0.8;
    transform: scale(0.5) rotate(180deg);
    filter: drop-shadow(0 0 60px rgba(247, 147, 26, 1)) brightness(2);
  }
  85% {
    opacity: 0;
    transform: scale(0) rotate(360deg);
    filter: drop-shadow(0 0 80px rgba(255, 255, 255, 1)) brightness(3);
  }
  100% {
    opacity: 0;
    transform: scale(0) rotate(360deg);
  }
}

/* Logo Bitcoin : apparaît avec explosion, pulse doré */
@keyframes splashLogoBitcoin {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
    filter: drop-shadow(0 0 0px rgba(247, 147, 26, 0));
  }
  60% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  70% {
    opacity: 1;
    transform: scale(1.4) rotate(0deg);
    filter: drop-shadow(0 0 50px rgba(247, 147, 26, 1)) brightness(2);
  }
  80% {
    transform: scale(0.9) rotate(10deg);
    filter: drop-shadow(0 0 30px rgba(247, 147, 26, 0.9));
  }
  88% {
    transform: scale(1.1) rotate(-5deg);
    filter: drop-shadow(0 0 25px rgba(247, 147, 26, 0.8));
  }
  95% {
    transform: scale(1) rotate(0deg);
    filter: drop-shadow(0 0 20px rgba(247, 147, 26, 0.7));
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
    filter: drop-shadow(0 0 15px rgba(247, 147, 26, 0.6));
  }
}

@keyframes splashTextPulse {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

@keyframes splashProgressBar {
  0%   { width: 0%; }
  100% { width: 100%; }
}

@keyframes splashFadeOut {
  0% {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

/* Flash blanc au moment de la transformation */
.splash-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(247, 147, 26, 0.6) 0%, transparent 70%);
  opacity: 0;
  animation: splashFlash 1.2s ease-in-out forwards;
  pointer-events: none;
}

@keyframes splashFlash {
  0%   { opacity: 0; }
  65%  { opacity: 0; }
  70%  { opacity: 1; }
  80%  { opacity: 0; }
  100% { opacity: 0; }
}