/* ============================================================
   Portfolio — dark, calm, data-dense financial dashboard
   Self-contained system-font stack. No external assets.
   ============================================================ */

/* Das native [hidden]-Attribut muss gegen explizite display-Regeln
   (z.B. .banner { display: flex }) gewinnen — sonst bleiben als
   hidden markierte Elemente sichtbar. */
[hidden] {
  display: none !important;
}

:root {
  /* --- surface & ink --- */
  --bg: #0b0f14;
  --bg-raised: #10161d;
  --bg-card: #121922;
  --bg-card-hover: #151d27;
  --line: #1f2934;
  --line-soft: #182029;

  --ink-1: #eef2f6;
  --ink-2: #a9b4c0;
  --ink-3: #6b7684;
  --ink-4: #4a535f;

  /* --- signal colors: used ONLY for status, never decoration --- */
  --ok: #5ad1a0;
  --ok-bg: rgba(90, 209, 160, 0.11);
  --ok-line: rgba(90, 209, 160, 0.28);

  --watch: #e8b25e;
  --watch-bg: rgba(232, 178, 94, 0.12);
  --watch-line: rgba(232, 178, 94, 0.3);

  --alert: #e07a6b;
  --alert-bg: rgba(224, 122, 107, 0.12);
  --alert-line: rgba(224, 122, 107, 0.3);

  --accent: #6fb6ff;
  --accent-bg: rgba(111, 182, 255, 0.1);

  /* --- type scale (1.2 minor third-ish, mobile-first) --- */
  --fs-11: 0.6875rem;
  --fs-13: 0.8125rem;
  --fs-15: 0.9375rem;
  --fs-17: 1.0625rem;
  --fs-22: 1.375rem;
  --fs-32: 2rem;
  --fs-40: 2.5rem;

  /* --- spacing scale --- */
  --sp-2: 0.125rem;
  --sp-4: 0.25rem;
  --sp-8: 0.5rem;
  --sp-12: 0.75rem;
  --sp-16: 1rem;
  --sp-20: 1.25rem;
  --sp-24: 1.5rem;
  --sp-32: 2rem;
  --sp-40: 2.5rem;

  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;

  --font-display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Menlo", Consolas, monospace;

  color-scheme: dark;
}

/* ---------------------------------------------------------------
   Reset & base
   --------------------------------------------------------------- */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(111, 182, 255, 0.05), transparent),
    var(--bg);
  color: var(--ink-1);
  font-family: var(--font-body);
  font-size: var(--fs-15);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100%;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

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

button {
  font: inherit;
  color: inherit;
}

/* ---------------------------------------------------------------
   Topbar
   --------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: calc(var(--sp-24) + env(safe-area-inset-top)) var(--sp-20) var(--sp-16);
}

.topbar__mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  flex-shrink: 0;
}

.topbar__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  margin-right: auto;
}

.topbar__eyebrow {
  font-size: var(--fs-11);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.topbar__title {
  font-family: var(--font-display);
  font-size: var(--fs-22);
  font-weight: 500;
  color: var(--ink-1);
}

.btn-ghost {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: var(--sp-8) var(--sp-12);
  font-size: var(--fs-13);
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn-ghost span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-ghost:active {
  background: var(--bg-card-hover);
}

.btn-ghost svg {
  flex-shrink: 0;
}

.btn-ghost.is-enabled {
  color: var(--ok);
  border-color: var(--ok-line);
  background: var(--ok-bg);
}

/* icon-only on very narrow screens */
@media (max-width: 380px) {
  .btn-ghost span {
    display: none;
  }
  .btn-ghost {
    padding: var(--sp-8);
  }
}

/* ---------------------------------------------------------------
   Banners
   --------------------------------------------------------------- */
.banner {
  margin: 0 var(--sp-20) var(--sp-16);
  padding: var(--sp-12) var(--sp-16);
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  display: flex;
  align-items: center;
  gap: var(--sp-8);
}

.banner--offline {
  background: var(--watch-bg);
  border: 1px solid var(--watch-line);
  color: var(--watch);
}

.banner__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.banner--hint {
  background: var(--bg-card);
  border: 1px solid var(--line);
  color: var(--ink-2);
  justify-content: space-between;
}

.banner__close {
  background: none;
  border: none;
  color: var(--ink-3);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 0 var(--sp-12);
  flex-shrink: 0;
}

/* ---------------------------------------------------------------
   Content / cards
   --------------------------------------------------------------- */
.content {
  padding: 0 var(--sp-20) var(--sp-40);
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
}

.loading {
  color: var(--ink-3);
  font-size: var(--fs-13);
  padding: var(--sp-32) 0;
  text-align: center;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: var(--sp-20);
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card + .card { }

.section-label {
  font-size: var(--fs-11);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: var(--sp-12);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------------------------------------------------------------
   Hero: total value
   --------------------------------------------------------------- */
.hero {
  padding: var(--sp-24) var(--sp-20) var(--sp-20);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle 220px at 88% -12%, rgba(111, 182, 255, 0.14), transparent 70%);
  pointer-events: none;
}

.hero__label {
  font-size: var(--fs-11);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  position: relative;
}

.hero__value {
  font-family: var(--font-display);
  font-size: var(--fs-40);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-top: var(--sp-4);
  position: relative;
  font-variant-numeric: tabular-nums;
}

.hero__delta {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
  margin-top: var(--sp-12);
  padding: var(--sp-4) var(--sp-8) var(--sp-4) var(--sp-4);
  border-radius: 100px;
  font-size: var(--fs-13);
  font-variant-numeric: tabular-nums;
  position: relative;
}

.hero__delta.is-up {
  background: var(--ok-bg);
  color: var(--ok);
}

.hero__delta.is-down {
  background: var(--alert-bg);
  color: var(--alert);
}

.hero__delta.is-flat {
  background: var(--bg-raised);
  color: var(--ink-3);
}

.hero__delta-icon {
  display: inline-flex;
}

.hero__timestamp {
  margin-top: var(--sp-16);
  font-size: var(--fs-11);
  color: var(--ink-4);
  position: relative;
}

.hero__timestamp .stale {
  color: var(--watch);
  margin-left: var(--sp-8);
}

/* ---------------------------------------------------------------
   Allocation ("Ampeln")
   --------------------------------------------------------------- */
.alloc-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-16);
}

.alloc-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: var(--sp-12);
  align-items: center;
}

.alloc-row__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  align-self: start;
  margin-top: 6px;
}

.alloc-row__dot.status-ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.alloc-row__dot.status-watch { background: var(--watch); box-shadow: 0 0 0 3px var(--watch-bg); }
.alloc-row__dot.status-alert { background: var(--alert); box-shadow: 0 0 0 3px var(--alert-bg); }

.alloc-row__main {
  min-width: 0;
}

.alloc-row__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-8);
  margin-bottom: var(--sp-8);
}

.alloc-row__name {
  font-size: var(--fs-15);
  color: var(--ink-1);
  line-height: 1.2;
}

.alloc-row__pct {
  font-size: var(--fs-13);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.alloc-row__pct b {
  color: var(--ink-1);
  font-weight: 600;
}

.track {
  position: relative;
  height: 6px;
  border-radius: 4px;
  background: var(--bg-raised);
  overflow: visible;
}

.track__fill {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.track__fill.status-ok { background: var(--ok); }
.track__fill.status-watch { background: var(--watch); }
.track__fill.status-alert { background: var(--alert); }

.track__target {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--ink-1);
  opacity: 0.55;
  border-radius: 1px;
}

.alloc-row__value {
  font-size: var(--fs-13);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
  align-self: start;
  white-space: nowrap;
}

.alloc-legend {
  margin-top: var(--sp-16);
  padding-top: var(--sp-16);
  border-top: 1px solid var(--line-soft);
  display: flex;
  gap: var(--sp-16);
  font-size: var(--fs-11);
  color: var(--ink-4);
  flex-wrap: wrap;
}

.alloc-legend span {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-4);
}

.alloc-legend i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.alloc-legend i.status-ok { background: var(--ok); }
.alloc-legend i.status-watch { background: var(--watch); }
.alloc-legend i.status-alert { background: var(--alert); }

/* ---------------------------------------------------------------
   Actions list
   --------------------------------------------------------------- */
.action-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.action-row {
  display: flex;
  align-items: center;
  gap: var(--sp-12);
  padding: var(--sp-12);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

.action-row__badge {
  font-size: var(--fs-11);
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: var(--sp-4) var(--sp-8);
  border-radius: 6px;
  flex-shrink: 0;
}

.action-row__badge.action-buy {
  background: var(--ok-bg);
  color: var(--ok);
}

.action-row__badge.action-reduce {
  background: var(--alert-bg);
  color: var(--alert);
}

.action-row__name {
  flex: 1;
  min-width: 0;
  line-height: 1.2;
  color: var(--ink-1);
}

.action-row__amount {
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-15);
  white-space: nowrap;
}

.action-row__amount.is-positive { color: var(--ok); }
.action-row__amount.is-negative { color: var(--alert); }

/* ---------------------------------------------------------------
   Sell candidates
   --------------------------------------------------------------- */
.sell-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-12);
}

.sell-row {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding-bottom: var(--sp-12);
  border-bottom: 1px solid var(--line-soft);
}

.sell-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.sell-row__ticker {
  font-family: var(--font-mono);
  font-size: var(--fs-15);
  color: var(--ink-1);
  letter-spacing: 0.01em;
}

.sell-row__reason {
  font-size: var(--fs-13);
  color: var(--ink-3);
}

/* ---------------------------------------------------------------
   DCA plan
   --------------------------------------------------------------- */
.dca-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-8);
}

.dca-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-8) 0;
}

.dca-row__name {
  color: var(--ink-2);
}

.dca-row__amount {
  font-variant-numeric: tabular-nums;
  color: var(--ink-1);
  font-weight: 500;
}

.dca-total {
  display: flex;
  justify-content: space-between;
  margin-top: var(--sp-12);
  padding-top: var(--sp-12);
  border-top: 1px solid var(--line-soft);
  font-size: var(--fs-13);
  color: var(--ink-3);
}

.dca-total b {
  color: var(--ink-1);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
   Empty / footer states
   --------------------------------------------------------------- */
.empty-hint {
  color: var(--ink-4);
  font-size: var(--fs-13);
  text-align: center;
  padding: var(--sp-8) 0;
}

.empty-state {
  text-align: center;
  padding: var(--sp-40) var(--sp-20);
  color: var(--ink-3);
}

.empty-state__title {
  font-family: var(--font-display);
  font-size: var(--fs-22);
  color: var(--ink-1);
  margin-bottom: var(--sp-8);
}

.empty-state__body {
  font-size: var(--fs-13);
}

.footer-note {
  text-align: center;
  font-size: var(--fs-11);
  color: var(--ink-4);
  padding: var(--sp-16) 0 var(--sp-8);
}

/* ---------------------------------------------------------------
   Staggered card entrance
   --------------------------------------------------------------- */
.content .card:nth-child(1) { animation-delay: 0ms; }
.content .card:nth-child(2) { animation-delay: 60ms; }
.content .card:nth-child(3) { animation-delay: 120ms; }
.content .card:nth-child(4) { animation-delay: 180ms; }
.content .card:nth-child(5) { animation-delay: 240ms; }

@media (prefers-reduced-motion: reduce) {
  .card, .banner__dot {
    animation: none !important;
  }
  .track__fill {
    transition: none !important;
  }
}

/* ---------------------------------------------------------------
   Slightly wider viewports: a touch more breathing room
   --------------------------------------------------------------- */
@media (min-width: 460px) {
  .hero__value {
    font-size: var(--fs-40);
  }
}
