:root {
  color-scheme: dark;
  --bg: #050816;
  --panel: #0d1328;
  --line: #202944;
  --text: #f4f7ff;
  --muted: #8e98b5;
  --accent: #7cf2c8;
  --danger: #ff7d90;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Space Grotesk', sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app {
  width: min(760px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.status,
input,
button {
  font-family: 'IBM Plex Mono', monospace;
}

.symbol-input {
  flex: 1;
  min-width: 0;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  text-transform: uppercase;
}

.symbol-input:focus {
  border-color: var(--accent);
}

.symbol-fields {
  display: flex;
  flex: 1;
  align-items: stretch;
  gap: 0.75rem;
}

.symbol-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.quantity-input {
  width: 128px;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.quantity-input:focus {
  border-color: var(--accent);
}

.remove-symbol {
  padding: 0.95rem 1rem;
  border: 1px solid rgba(255, 125, 144, 0.35);
  border-radius: 12px;
  background: rgba(255, 125, 144, 0.08);
  color: var(--danger);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.remove-symbol:hover {
  border-color: var(--danger);
  background: rgba(255, 125, 144, 0.14);
}

.status {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.refresh-progress {
  overflow: hidden;
  height: 6px;
  margin: -0.45rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.refresh-progress-bar {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(124, 242, 200, 0.35), var(--accent));
  transform: scaleX(0);
  transform-origin: left center;
}

.status[data-error='true'] {
  color: var(--danger);
}

.portfolio-summary {
  margin: 0 0 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(124, 242, 200, 0.12), rgba(124, 242, 200, 0.02)),
    var(--panel);
}

.summary-label,
.summary-total {
  margin: 0;
}

.summary-label {
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-total {
  margin-top: 0.35rem;
  color: var(--accent);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1;
}

.allocation-chart {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.history-chart {
  margin-top: 1rem;
}

.allocation-pie {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px solid rgba(124, 242, 200, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.allocation-pie svg {
  width: min(100%, 220px);
  height: auto;
}

.portfolio-history {
  min-height: 236px;
  padding: 0.45rem 1rem 0.7rem;
  border: 1px solid rgba(124, 242, 200, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.portfolio-history svg {
  display: block;
  width: 100%;
  height: auto;
}

.history-header,
.history-label,
.history-change {
  margin: 0;
}

.history-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.1rem;
}

.history-label,
.history-change,
.history-tick {
  font-family: 'IBM Plex Mono', monospace;
}

.history-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-change {
  font-size: 0.86rem;
}

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

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

.history-axis {
  stroke: rgba(244, 247, 255, 0.12);
  stroke-width: 1;
}

.history-area {
  fill: url(#portfolio-history-fill);
}

.history-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-dot {
  fill: var(--accent);
  stroke: #0d1328;
  stroke-width: 1.5;
}

.history-tick {
  fill: var(--muted);
  font-size: 8px;
}

.history-value {
  text-anchor: end;
}

.history-guide {
  stroke: rgba(244, 247, 255, 0.5);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.history-guide-value {
  fill: var(--text);
}

.history-dot.active {
  stroke-width: 2;
}

.history-hit-area {
  cursor: pointer;
}

.history-hit-area:focus-visible {
  outline: none;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.allocation-pie-label {
  fill: #050816;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 7px;
  font-weight: 500;
  text-anchor: middle;
  dominant-baseline: middle;
}

.allocation-empty {
  max-width: 12rem;
  margin: 0;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.allocation-swatch {
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 999px;
  flex: 0 0 auto;
}

.allocation-share {
  margin: 0;
}

.allocation-share {
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  white-space: nowrap;
}

.position-value-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.65rem;
}

.allocation-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

.symbol-allocation {
  min-width: 4.5rem;
}

.symbol-allocation .allocation-share {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.symbols-list {
  display: grid;
  gap: 0.75rem;
}

.symbol-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.symbol-row.error {
  border-color: rgba(255, 125, 144, 0.3);
}

.price,
.meta,
.position-total,
.quote-label,
.quote-line {
  margin: 0;
}

.symbol-quote {
  min-width: 220px;
  text-align: right;
}

.quote-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.quote-line + .quote-line {
  margin-top: 0.35rem;
}

.quote-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.meta {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.price,
.position-total {
  font-size: clamp(1.1rem, 2.8vw, 1.45rem);
  line-height: 1.1;
}

.price {
  color: var(--accent);
}

.add-symbol {
  display: grid;
  place-items: center;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.add-symbol:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.share-panel {
  margin-top: 1rem;
}

.share-label {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.share-url {
  width: 100%;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.92rem;
}

.share-url:focus {
  border-color: var(--accent);
  outline: none;
}

@media (max-width: 720px) {
  .allocation-pie {
    min-height: 180px;
  }

  .portfolio-history {
    min-height: 212px;
    padding-inline: 0.8rem;
  }

  .symbol-row {
    flex-direction: column;
    align-items: stretch;
  }

  .symbol-fields {
    flex-direction: column;
  }

  .symbol-main {
    width: 100%;
  }

  .quantity-input {
    width: 100%;
  }

  .symbol-quote {
    min-width: 0;
    text-align: left;
  }
}
