body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI";
  background: #f5f6f8;
}

/* App 外框 */
.container {
  max-width: 420px;
  margin: 0 auto;
  padding: 16px;
}

/* 標題 */
h2 {
  text-align: center;
  margin: 10px 0 20px;
}

h3 {
  margin: 0;
}

/* 卡片 */
.card {
  background: white;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 輸入框 */
input {
  width: 100%;
  padding: 12px;
  margin: 6px 0;
  border-radius: 10px;
  border: 1px solid #ddd;
  font-size: 16px;
  box-sizing: border-box;
}

/* 按鈕 */
button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: #007aff;
  color: white;
  font-size: 16px;
  margin-top: 8px;
}

button:active {
  opacity: 0.8;
}

/* 資料顯示 */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}

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

/* 現金 row 裡的 input 不需要滿版樣式 */
.price-row input {
  width: 110px;
  margin: 0;
  padding: 8px;
  text-align: right;
}

/* ===== 資產總額卡片 ===== */
.total-card {
  background: linear-gradient(135deg, #007aff, #5856d6);
  color: white;
  text-align: center;
}

.total-label {
  font-size: 14px;
  opacity: 0.85;
}

.total-value {
  font-size: 32px;
  font-weight: 700;
  margin: 6px 0 10px;
}

.total-sub {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  opacity: 0.95;
}

.total-sub-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cash-input {
  width: 80px;
  margin: 0;
  padding: 4px 6px;
  font-size: 13px;
  border-radius: 6px;
  border: none;
  color: #222;
}

.cash-edit-btn {
  width: auto;
  margin: 0;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.22);
  color: white;
  border-radius: 6px;
}

/* ===== 可收合的區塊標題 ===== */
.toggle-header {
  cursor: pointer;
  user-select: none;
}

.toggle-icon {
  font-size: 18px;
  font-weight: 700;
  color: #007aff;
  width: auto;
}

.add-form-body {
  margin-top: 8px;
}

.add-form-body.collapsed {
  display: none;
}

/* ===== 自動完成下拉選單 ===== */
.autocomplete-wrap {
  position: relative;
}

.suggest-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 10px;
  margin-top: -2px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.suggest-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 15px;
  border-bottom: 1px solid #f0f0f0;
}

.suggest-item:last-child {
  border-bottom: none;
}

.suggest-item:active {
  background: #f5f6f8;
}

.suggest-price {
  color: #007aff;
  font-weight: 600;
}

/* ===== 股價更新狀態文字 ===== */
.price-status {
  font-size: 12px;
  color: #999;
  text-align: center;
  margin-top: 6px;
}

/* ===== 股票清單 ===== */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ghost-btn {
  width: auto;
  margin-top: 0;
  padding: 6px 12px;
  font-size: 13px;
  background: white;
  color: #007aff;
  border: 1px solid #007aff;
}

/* 表格欄位標題 */
.stock-table-header {
  display: grid;
  grid-template-columns: 2fr 0.8fr 1.3fr 28px;
  gap: 6px;
  padding: 10px 0 4px;
  font-size: 12px;
  color: #999;
  font-weight: 600;
}

/* 每一筆股票（股名 / 股數 / 總損益 / 刪除） */
.stock-row-compact {
  display: grid;
  grid-template-columns: 2fr 0.8fr 1.3fr 28px;
  gap: 6px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.stock-row-compact:last-of-type {
  border-bottom: none;
}

.stock-name {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  overflow: hidden;
}

.stock-name b {
  font-size: 14px;
}

.stock-name small {
  color: #999;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.del-btn-sm {
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  font-size: 16px;
  line-height: 28px;
  background: #fff0f0;
  color: #ff3b30;
  border-radius: 8px;
}

.empty-tip {
  text-align: center;
  color: #999;
  padding: 16px 0;
  font-size: 14px;
}

.stock-summary {
  margin-top: 4px;
  border-top: 2px solid #f0f0f0;
  padding-top: 4px;
}

/* 損益顏色（台股習慣：紅漲綠跌） */
.pl-pos {
  color: #ff3b30;
  font-weight: 600;
}

.pl-neg {
  color: #34c759;
  font-weight: 600;
}
