* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--tg-theme-bg-color, #1c1c1e);
  color: var(--tg-theme-text-color, #ffffff);
  min-height: 100vh;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
header {
  text-align: center;
  padding: 8px 0 20px;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  opacity: 0.7;
  margin-bottom: 8px;
}

.total-value .label {
  display: block;
  font-size: 13px;
  opacity: 0.5;
  margin-bottom: 4px;
}

.total-value .amount {
  display: block;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
}

.total-value .pnl {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 8px;
}

.pnl.positive {
  color: #34c759;
  background: rgba(52, 199, 89, 0.12);
}

.pnl.negative {
  color: #ff3b30;
  background: rgba(255, 59, 48, 0.12);
}

.pnl.neutral {
  color: var(--tg-theme-hint-color, #8e8e93);
  background: rgba(142, 142, 147, 0.12);
}

/* Holdings list */
.holdings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 16px;
}

.empty-state .hint {
  font-size: 13px;
  margin-top: 8px;
}

/* Token card */
.token-card {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--tg-theme-secondary-bg-color, #2c2c2e);
  border-radius: 12px;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.token-card:active {
  transform: scale(0.98);
}

.token-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--tg-theme-bg-color, #1c1c1e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.token-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.token-info {
  flex: 1;
  min-width: 0;
}

.token-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.token-holdings {
  font-size: 13px;
  opacity: 0.5;
  margin-top: 2px;
}

.token-values {
  text-align: right;
  flex-shrink: 0;
}

.token-current-value {
  font-size: 15px;
  font-weight: 600;
}

.token-pnl {
  font-size: 13px;
  font-weight: 500;
  margin-top: 2px;
}

.token-pnl.positive { color: #34c759; }
.token-pnl.negative { color: #ff3b30; }
.token-pnl.neutral { color: var(--tg-theme-hint-color, #8e8e93); }

/* Loading state on cards */
.token-card.loading .token-current-value,
.token-card.loading .token-pnl {
  background: var(--tg-theme-bg-color, #1c1c1e);
  color: transparent;
  border-radius: 4px;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* FAB */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--tg-theme-button-color, #007aff);
  color: var(--tg-theme-button-text-color, #ffffff);
  font-size: 28px;
  font-weight: 300;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
}

.fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--tg-theme-secondary-bg-color, #2c2c2e);
  border-radius: 16px 16px 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

.modal-small {
  text-align: center;
}

.modal-small p {
  margin: 12px 0 20px;
  opacity: 0.7;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.6;
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: var(--tg-theme-bg-color, #1c1c1e);
  color: var(--tg-theme-text-color, #ffffff);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus {
  border-color: var(--tg-theme-button-color, #007aff);
}

.form-group input::placeholder {
  color: var(--tg-theme-hint-color, #8e8e93);
}

/* Search results dropdown */
.search-results {
  display: none;
  margin-top: 4px;
  border-radius: 10px;
  background: var(--tg-theme-bg-color, #1c1c1e);
  max-height: 200px;
  overflow-y: auto;
}

.search-results.active {
  display: block;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  gap: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.search-result-item:active {
  background: rgba(255, 255, 255, 0.05);
}

.search-result-item img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.search-result-item .name {
  font-size: 14px;
  font-weight: 600;
}

.search-result-item .symbol {
  font-size: 12px;
  opacity: 0.5;
  margin-left: 4px;
  text-transform: uppercase;
}

.search-results .loading-text,
.search-results .no-results {
  padding: 12px 14px;
  font-size: 13px;
  opacity: 0.5;
  text-align: center;
}

/* Buttons */
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.btn {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.7;
}

.btn-cancel {
  background: var(--tg-theme-bg-color, #1c1c1e);
  color: var(--tg-theme-text-color, #ffffff);
}

.btn-confirm {
  background: var(--tg-theme-button-color, #007aff);
  color: var(--tg-theme-button-text-color, #ffffff);
}

.btn-danger {
  background: #ff3b30;
  color: #ffffff;
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Refresh indicator */
.refreshing header h1::after {
  content: ' ...';
  animation: pulse 1s ease-in-out infinite;
}
