/* Theme ported from ios/NaviIOS/Sources/NaviClientUI/PortfolioTheme.swift */

@font-face {
  font-family: "Barlow Semi Condensed";
  font-weight: 300;
  font-display: swap;
  src: url("/fonts/BarlowSemiCondensed-300.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Semi Condensed";
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/BarlowSemiCondensed-400.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Semi Condensed";
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/BarlowSemiCondensed-500.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Semi Condensed";
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/BarlowSemiCondensed-600.woff2") format("woff2");
}
@font-face {
  font-family: "Barlow Semi Condensed";
  font-weight: 700;
  font-display: swap;
  src: url("/fonts/BarlowSemiCondensed-700.woff2") format("woff2");
}

:root {
  --positive: #00c978;
  --negative: #ff4757;
  --background: #0a0a0c;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.85);
  --text-tertiary: rgba(255, 255, 255, 0.22);
  --section-header: rgba(255, 255, 255, 0.25);
  --percent-text: rgba(255, 255, 255, 0.3);
  --divider: rgba(255, 255, 255, 0.06);
  --total-divider: rgba(255, 255, 255, 0.1);
  --tab-active: #0a84ff;
  --tab-inactive: rgba(255, 255, 255, 0.3);
  --flat: rgba(255, 255, 255, 0.35);
  --card: #17171a;
  --font: "Barlow Semi Condensed", -apple-system, "SF Pro Text", system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  background: var(--background);
  color: var(--text-primary);
  font-family: var(--font);
  height: 100%;
  overscroll-behavior-y: contain;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(96px + env(safe-area-inset-bottom));
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ---- tab bar ---- */

.tabbar[hidden] {
  display: none;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 64px;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  background: rgba(10, 10, 12, 0.86);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 0.5px solid var(--divider);
  z-index: 30;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--tab-inactive);
  font-size: 11px;
  font-weight: 500;
}

.tab svg {
  width: 24px;
  height: 24px;
}

.tab[aria-selected="true"] {
  color: var(--tab-active);
}

/* ---- portfolio hero ---- */

.hero-total {
  font-size: 46px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.1;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff 0%, rgba(255, 255, 255, 0.7) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subrow {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 6px;
}

.hero-status {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-tertiary);
}

.hero-spacer {
  flex: 1;
}

.hero-daypnl {
  font-size: 19px;
  font-weight: 600;
}

.hero-daypnl.up { color: var(--positive); }
.hero-daypnl.down { color: var(--negative); }
.hero-daypnl.flat { color: var(--text-secondary); }

.hero-daypct {
  font-size: 13px;
  font-weight: 400;
  color: var(--percent-text);
}

/* ---- rules / rows ---- */

.rule {
  height: 0.5px;
  background: var(--divider);
}

.rule.total {
  height: 1px;
  background: var(--total-divider);
}

.refresh-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.refresh-note.warn { color: #ff9f0a; }
.refresh-note.live { color: var(--positive); }
.refresh-note.muted { color: var(--text-tertiary); }

.live-dot {
  width: 7px;
  height: 7px;
  flex: none;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 0 0 rgba(0, 201, 120, 0.55);
  animation: live-pulse 2s ease-out infinite;
}

@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 201, 120, 0.5); }
  70% { box-shadow: 0 0 0 6px rgba(0, 201, 120, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 201, 120, 0); }
}

.placeholder-row {
  padding: 12px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---- asset groups ---- */

.asset-group {
  padding: 14px 0;
}

.asset-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: left;
}

.asset-titles {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.asset-name {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-detail {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.asset-spark {
  width: 68px;
  height: 30px;
  flex: none;
}

.asset-quote {
  min-width: 82px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.asset-price {
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.3px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.asset-change {
  font-size: 14px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 5px;
  white-space: nowrap;
}

.asset-change.up {
  color: var(--positive);
  background: rgba(0, 201, 120, 0.14);
}

.asset-change.down {
  color: var(--negative);
  background: rgba(255, 71, 87, 0.14);
}

.asset-change.flat {
  color: var(--flat);
  background: rgba(255, 255, 255, 0.06);
}

/* issue badges */

.issue-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.issue-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 6px;
  border-radius: 999px;
}

.issue-badge.missing { color: var(--negative); background: rgba(255, 71, 87, 0.14); }
.issue-badge.stale { color: rgba(255, 159, 10, 0.9); background: rgba(255, 159, 10, 0.14); }
.issue-badge.delayed { color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.06); }
.issue-badge.broker_mark { color: rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.06); }

/* expanded entries */

.entry-list {
  margin-top: 12px;
}

.entry-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 9px 0 9px 12px;
}

.entry-titles {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.entry-detail {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.entry-account {
  font-size: 12px;
  color: var(--text-tertiary);
}

.entry-values {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.entry-value {
  font-size: 15px;
  color: var(--text-secondary);
}

.entry-pnl {
  font-size: 12px;
}

.entry-pnl.up { color: var(--positive); }
.entry-pnl.down { color: var(--negative); }
.entry-pnl.flat { color: var(--text-secondary); }
.entry-pnl.none { color: var(--text-tertiary); }

/* ---- data sections (Cash / Other Assets / Error) ---- */

.data-section {
  margin-top: 30px;
}

.data-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--section-header);
  padding-bottom: 8px;
}

.metric-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.metric-label {
  flex: 1;
  font-size: 19px;
  font-weight: 600;
}

.metric-value {
  font-size: 19px;
  font-weight: 400;
  letter-spacing: -0.3px;
  color: var(--text-secondary);
  text-align: right;
}

.metric-value.emphasized {
  font-weight: 600;
  color: var(--text-primary);
}

.metric-value.negative {
  color: var(--negative);
}

.last-updated {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.error-text {
  padding: 12px 0;
  font-size: 14px;
  color: var(--negative);
  overflow-wrap: anywhere;
}

/* ---- pull-to-refresh substitute ---- */

.refresh-fab {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  right: 14px;
  z-index: 40;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tab-inactive);
  background: rgba(255, 255, 255, 0.04);
}

.refresh-fab svg {
  width: 18px;
  height: 18px;
}

.refresh-fab.busy svg {
  animation: spin 0.8s linear infinite;
}

/* ---- settings (iOS inset grouped form, dark) ---- */

.settings-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 18px 0 12px;
}

.form-section {
  margin-bottom: 22px;
}

.form-section-header {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--section-header);
  padding: 0 16px 7px;
}

.form-card {
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 11px 16px;
  font-size: 17px;
  font-weight: 400;
  text-align: left;
  position: relative;
}

.form-row + .form-row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 0;
  height: 0.5px;
  background: rgba(255, 255, 255, 0.08);
}

.form-row .row-label {
  flex: 1;
  min-width: 0;
}

.row-sub {
  display: block;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.row-value {
  color: rgba(255, 255, 255, 0.55);
  text-align: right;
  overflow-wrap: anywhere;
}

.row-value.ok { color: var(--positive); }

.form-row.action { color: var(--tab-active); }
.form-row.destructive { color: var(--negative); }
.form-row:disabled { opacity: 0.4; }

.chevron {
  flex: none;
  width: 8px;
  height: 8px;
  border-right: 1.8px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1.8px solid rgba(255, 255, 255, 0.35);
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
}

.chevron.open {
  transform: rotate(45deg);
}

.edit-glyph {
  flex: none;
  color: rgba(255, 255, 255, 0.35);
}

/* ---- pairing ---- */

.pair-wrap {
  min-height: 80dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.pair-title {
  font-size: 34px;
  font-weight: 700;
}

.pair-sub {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.field {
  width: 100%;
  background: var(--card);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 17px;
  padding: 14px 16px;
  outline: none;
}

.field:focus {
  border-color: var(--tab-active);
}

.button-primary {
  background: var(--tab-active);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  border-radius: 12px;
  padding: 15px;
}

.button-primary:disabled {
  opacity: 0.5;
}

/* ---- modal sheet (editors) ---- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 88dvh;
  overflow-y: auto;
  background: #131316;
  border-radius: 16px 16px 0 0;
  padding: 14px 20px calc(24px + env(safe-area-inset-bottom));
}

.sheet-handle {
  width: 38px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 auto 12px;
}

.sheet-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.sheet-title {
  font-size: 20px;
  font-weight: 600;
}

.sheet-action {
  color: var(--tab-active);
  font-size: 17px;
  font-weight: 500;
  padding: 6px 0;
}

.sheet-action.destructive { color: var(--negative); }

.sheet label {
  display: block;
  font-size: 13px;
  color: var(--section-header);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 14px 2px 6px;
}

@media (min-width: 700px) {
  .page { padding-top: 28px; }
}
