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

body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}

.container {
max-width: 1400px;
margin: 0 auto;
}

.header {
background: white;
border-radius: 10px;
padding: 20px;
margin-bottom: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.header h1 {
color: #333;
margin-bottom: 10px;
font-size: 24px;
}

.header .info {
color: #666;
font-size: 14px;
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
}

.tabs {
display: flex;
gap: 10px;
margin-bottom: 20px;
}

.tab {
background: white;
border: none;
padding: 12px 24px;
border-radius: 8px 8px 0 0;
cursor: pointer;
font-size: 16px;
font-weight: 500;
color: #666;
transition: all 0.3s;
}

.tab.active {
background: white;
color: #667eea;
border-bottom: 3px solid #667eea;
}

.tab-content {
display: none;
background: white;
border-radius: 0 10px 10px 10px;
padding: 20px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.tab-content.active {
display: block;
}

.stats {
display: flex;
gap: 20px;
margin-bottom: 20px;
flex-wrap: wrap;
}

.stat-group {
flex: 1;
min-width: 300px;
background: white;
border-radius: 10px;
padding: 15px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-group-header {
font-size: 16px;
font-weight: 600;
color: #333;
margin-bottom: 15px;
padding-bottom: 10px;
border-bottom: 2px solid #f0f0f0;
}

.stat-group-content {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 15px;
}

.stat-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
font-size: 14px;
opacity: 0.9;
margin-bottom: 10px;
}

.stat-card .value {
font-size: 24px;
font-weight: bold;
word-break: break-all;
overflow-wrap: break-word;
}

.stat-card.positive .value {
color: #4ade80;
}

.stat-card.negative .value {
color: #f87171;
}

table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
position: relative;
}

th, td {
padding: 12px;
text-align: left;
border-bottom: 1px solid #eee;
}

th {
background: #f8f9fa;
font-weight: 600;
color: #333;
position: sticky;
top: 0;
}

tr:hover {
background: #f8f9fa;
}

/* 观察列表已触发策略的行样式 */
.watchlist-triggered {
background: #fef3c7 !important; /* 浅黄色背景，表示已触发 */
border-left: 3px solid #f59e0b; /* 左侧黄色边框，更明显 */
}

.watchlist-triggered:hover {
background: #fde68a !important; /* 悬停时稍深的黄色 */
}

/* 移动端已触发行的样式 */
@media screen and (max-width: 768px) {
.watchlist-triggered {
background: #fef3c7 !important;
border-left: 3px solid #f59e0b;
}
}

.action-dropdown {
position: relative;
display: inline-block;
}

.action-dropdown-btn {
background: #667eea;
color: white;
border: none;
padding: 6px 12px;
border-radius: 4px;
cursor: pointer;
font-size: 12px;
transition: background 0.3s;
}

.action-dropdown-btn:hover {
background: #5568d3;
}

.action-dropdown-content {
display: none;
position: absolute;
right: 0;
bottom: 100%;
background-color: white;
min-width: 120px;
box-shadow: 0px -4px 16px 0px rgba(0,0,0,0.2);
z-index: 10000;
border-radius: 4px;
overflow: hidden;
margin-bottom: 4px;
border: 1px solid #e5e7eb;
}

.action-dropdown-content.show {
display: block;
}

.action-dropdown-item {
color: #333;
padding: 10px 16px;
text-decoration: none;
display: block;
cursor: pointer;
font-size: 13px;
transition: background 0.2s;
}

.action-dropdown-item:hover {
background-color: #f1f1f1;
}

.action-dropdown-item.buy {
color: #10b981;
}

.action-dropdown-item.buy:hover {
background-color: #d1fae5;
}

.action-dropdown-item.sell {
color: #ef4444;
}

.action-dropdown-item.sell:hover {
background-color: #fee2e2;
}

.action-dropdown-item.delete {
color: #6b7280;
}

.action-dropdown-item.delete:hover {
background-color: #f3f4f6;
}

.action-dropdown-item.cancel {
display: none;
color: #667eea;
font-weight: 600;
}

.status-badge {
display: inline-block;
padding: 4px 12px;
border-radius: 12px;
font-size: 12px;
font-weight: 500;
}

.status-open {
background: #dbeafe;
color: #1e40af;
}

.status-closed {
background: #f3f4f6;
color: #6b7280;
}

.positive {
color: #10b981;
font-weight: 600;
}

.negative {
color: #ef4444;
font-weight: 600;
}

.refresh-btn {
background: #667eea;
color: white;
border: none;
padding: 10px 20px;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
margin-left: 10px;
transition: background 0.3s;
}

.refresh-btn:hover {
background: #5568d3;
}

.loading {
text-align: center;
padding: 12px;
// margin: 12px 8px 12px 8px;
color: #666;
}

.error {
background: #fee;
color: #c33;
padding: 15px;
border-radius: 6px;
margin: 20px 0;
}

.empty {
text-align: center;
padding: 40px;
color: #999;
}

.market-group {
margin-bottom: 30px;
padding: 0;
}

.market-header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 12px 20px;
border-radius: 8px 8px 0 0;
font-weight: 600;
font-size: 16px;
margin-bottom: 0;
}

.market-header.cnx {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.market-header.hkd {
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.market-table-wrapper {
background: white;
border-radius: 0 0 10px 10px;
overflow: visible;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

table {
overflow: visible;
}

tbody {
overflow: visible;
}

td {
overflow: visible;
}


.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
background-color: white;
margin: 10% auto;
padding: 30px;
border-radius: 10px;
width: 90%;
max-width: 500px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}

.modal-header h2 {
margin: 0;
color: #333;
}

.close {
color: #aaa;
font-size: 28px;
font-weight: bold;
cursor: pointer;
line-height: 20px;
}

.close:hover {
color: #000;
}

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

.form-group label {
display: block;
margin-bottom: 8px;
color: #333;
font-weight: 500;
}

.form-group input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 14px;
box-sizing: border-box;
}

.form-group input:focus {
outline: none;
border-color: #667eea;
}

.form-actions {
display: flex;
gap: 10px;
justify-content: flex-end;
margin-top: 30px;
}

.btn {
padding: 10px 20px;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
font-weight: 500;
transition: all 0.3s;
}

.btn-primary {
background: #667eea;
color: white;
}

.btn-primary:hover {
background: #5568d3;
}

.btn-secondary {
background: #6b7280;
color: white;
}

.btn-secondary:hover {
background: #4b5563;
}

.btn-success {
background: #10b981;
color: white;
}

.btn-success:hover {
background: #059669;
}

.btn-danger {
background: #ef4444;
color: white;
}

.btn-danger:hover {
background: #dc2626;
}

.message {
padding: 12px;
border-radius: 6px;
margin-bottom: 15px;
display: none;
}

.message.success {
background: #d1fae5;
color: #065f46;
border: 1px solid #10b981;
}

.message.error {
background: #fee2e2;
color: #991b1b;
border: 1px solid #ef4444;
}

.stock-select-wrapper {
position: relative;
}

.stock-dropdown {
display: none;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: white;
border: 1px solid #ddd;
border-radius: 6px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
max-height: 300px;
overflow-y: auto;
z-index: 1000;
margin-top: 4px;
}

.stock-dropdown.show {
display: block;
}

.stock-dropdown-item {
padding: 10px 15px;
cursor: pointer;
border-bottom: 1px solid #f0f0f0;
transition: background 0.2s;
}

.stock-dropdown-item:hover {
background: #f8f9fa;
}

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

.stock-dropdown-item .stock-code {
font-weight: 600;
color: #333;
margin-right: 8px;
}

.stock-dropdown-item .stock-name {
color: #666;
font-size: 14px;
}

.stock-dropdown-item .stock-market {
float: right;
font-size: 12px;
color: #999;
margin-top: 2px;
}

.stock-dropdown-empty {
padding: 20px;
text-align: center;
color: #999;
}

.stock-dropdown-loading {
padding: 20px;
text-align: center;
color: #666;
}

/* ========== 移动端响应式适配 ========== */

/* 表格容器 - 桌面端不限制overflow以便下拉框正常显示 */
.table-responsive {
width: 100%;
overflow: visible;
position: relative;
}


/* 小屏幕设备 (手机横屏及以下) */
@media screen and (max-width: 768px) {
body {
padding: 8px 0;
}

.container {
padding: 0;
margin: 0;
max-width: 100%;
width: 100%;
}

.header {
padding: 12px;
margin: 0 8px 10px 8px;
border-radius: 8px;
}

.header h1 {
font-size: 20px;
}

.header .info {
display: flex;
flex-direction: column;
gap: 10px;
align-items: flex-start;
}

.refresh-btn {
margin-left: 0;
width: 100%;
padding: 12px 20px;
}

/* 统计卡片 - 移动端横向排列 */
.stats {
flex-direction: column;
gap: 10px;
margin: 0 8px 12px 8px;
}

.stat-group {
min-width: unset;
width: 100%;
padding: 12px;
border-radius: 8px;
margin: 0;
}

.stat-group-header {
font-size: 14px;
margin-bottom: 10px;
padding-bottom: 8px;
}

.stat-group-content {
grid-template-columns: repeat(3, 1fr);
gap: 8px;
}

.stat-card {
padding: 12px 8px;
border-radius: 8px;
}

.stat-card h3 {
font-size: 11px;
margin-bottom: 6px;
}

.stat-card .value {
font-size: 14px;
word-break: break-all;
line-height: 1.2;
}

/* Tab 按钮 - 移动端适配 */
.tabs {
flex-wrap: wrap;
gap: 6px;
margin: 0 8px 10px 8px;
}

.tab {
padding: 10px 14px;
font-size: 14px;
flex: 1;
min-width: 70px;
text-align: center;
border-radius: 8px 8px 0 0;
}

.tab:last-child {
margin-left: 0 !important;
flex: none;
width: 100%;
}

/* 股票列表区域 - 移动端全宽显示 */
.tab-content {
padding: 0;
margin: 0;
border-radius: 0;
background: transparent;
box-shadow: none;
width: 100%;
}

#openContent,
#closedContent {
width: 100%;
}

/* 市场分组 - 撑满容器宽度 */
.market-group {
margin: 0 0 10px 0;
padding: 0;
width: 100%;
max-width: 100%;
box-sizing: border-box;
}

.market-header {
padding: 10px 12px;
font-size: 14px;
border-radius: 0;
margin: 0;
width: 100%;
box-sizing: border-box;
}

.market-table-wrapper {
border-radius: 0;
margin: 0;
padding: 0;
width: 100%;
box-sizing: border-box;
background: white; /* 确保移动端也有白色背景 */
}

/* 表格容器 - 移动端支持水平滚动 */
.table-responsive {
overflow-x: auto;
-webkit-overflow-scrolling: touch;
margin: 0;
padding: 0;
width: 100%;
box-sizing: border-box;
}

/* 表格 - 移动端优化 */
table {
min-width: 800px;
font-size: 12px;
margin: 0;
}

th, td {
padding: 10px 8px;
white-space: nowrap;
}

/* 移动端禁用表格行悬停效果，确保与web版一致 */
tr:hover {
background: inherit;
}

th:first-child, td:first-child {
padding-left: 12px;
}

th:last-child, td:last-child {
padding-right: 12px;
}

/* 操作下拉按钮 - 增大触摸区域 */
.action-dropdown-btn {
padding: 10px 16px;
font-size: 14px;
}

/* 移动端使用底部操作菜单样式 */
.action-dropdown-content {
position: fixed;
left: 0;
right: 0;
bottom: 0;
top: auto;
min-width: 100%;
width: 100%;
border-radius: 16px 16px 0 0;
margin-top: 0;
padding-bottom: env(safe-area-inset-bottom, 10px);
box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
z-index: 10001;
animation: slideUp 0.2s ease-out;
}

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

.action-dropdown-content::before {
content: '';
display: block;
width: 40px;
height: 4px;
background: #ddd;
border-radius: 2px;
margin: 12px auto;
}

.action-dropdown-item {
padding: 16px 20px;
font-size: 16px;
text-align: center;
border-bottom: 1px solid #f0f0f0;
}

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

.action-dropdown-item.cancel {
display: block;
margin-top: 8px;
background: #f5f5f5;
border-radius: 8px;
margin: 8px 10px 10px 10px;
padding: 14px 20px;
}

/* 底部操作菜单遮罩层 */
.action-sheet-overlay {
display: none;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.4);
z-index: 10000;
}

.action-sheet-overlay.show {
display: block;
}

/* 模态框 - 移动端全屏 */
.modal-content {
margin: 5% auto;
padding: 20px;
width: 95%;
max-width: none;
max-height: 90vh;
overflow-y: auto;
}

.modal-header h2 {
font-size: 18px;
}

.close {
font-size: 32px;
padding: 5px;
}

/* 表单 - 移动端优化 */
.form-group {
margin-bottom: 15px;
}

.form-group label {
font-size: 14px;
}

.form-group input {
padding: 12px;
font-size: 16px; /* 防止 iOS 自动缩放 */
}

.form-actions {
flex-direction: column;
gap: 10px;
}

.form-actions .btn {
width: 100%;
padding: 14px 20px;
font-size: 16px;
}

/* 股票下拉框 */
.stock-dropdown {
max-height: 250px;
}

.stock-dropdown-item {
padding: 14px 15px;
}

.stock-dropdown-item .stock-code {
font-size: 15px;
}

.stock-dropdown-item .stock-name {
font-size: 13px;
}

/* 退出规则模态框 */
#exitRulesModal .modal-content {
max-width: none;
}

#exitRulesContent {
max-height: calc(90vh - 100px);
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}

#exitRulesContent > div > div {
padding: 12px !important;
}

#exitRulesContent h4 {
font-size: 14px !important;
}

#exitRulesContent .value-text {
font-size: 13px !important;
}

/* 状态徽章 */
.status-badge {
padding: 6px 10px;
font-size: 11px;
}

/* 按钮通用优化 - 增大触摸区域 */
.btn {
min-height: 44px;
min-width: 44px;
}
}

/* 超小屏幕设备 (手机竖屏) */
@media screen and (max-width: 480px) {
body {
padding: 6px 0;
}

.header {
padding: 10px;
border-radius: 6px;
margin: 0 6px 8px 6px;
}

.header h1 {
font-size: 16px;
}

.header .info {
font-size: 12px;
gap: 8px;
}

/* 汇总数据保持适当留白 */
.stats {
gap: 8px;
margin: 0 6px 10px 6px;
}

.stat-group {
padding: 10px;
border-radius: 6px;
}

.stat-group-header {
font-size: 13px;
margin-bottom: 8px;
}

.stat-card {
padding: 10px 6px;
border-radius: 6px;
}

.stat-card h3 {
font-size: 10px;
}

.stat-card .value {
font-size: 12px;
word-break: break-all;
line-height: 1.2;
}

.tabs {
gap: 4px;
margin: 0 6px 8px 6px;
}

.tab {
padding: 8px 10px;
font-size: 13px;
min-width: 60px;
}

/* 股票列表全宽 */
.tab-content {
margin: 0;
width: 100%;
}

#openContent,
#closedContent {
width: 100%;
}

/* 市场分组 - 撑满容器宽度 */
.market-group {
margin: 0 0 8px 0;
padding: 0;
width: 100%;
box-sizing: border-box;
}

.market-header {
padding: 8px 10px;
font-size: 13px;
width: 100%;
box-sizing: border-box;
}

.market-table-wrapper {
width: 100%;
box-sizing: border-box;
}

.table-responsive {
width: 100%;
box-sizing: border-box;
}

table {
min-width: 750px;
font-size: 11px;
}

th, td {
padding: 8px 6px;
}

/* 超小屏幕禁用表格行悬停效果 */
tr:hover {
background: inherit;
}

th:first-child, td:first-child {
padding-left: 10px;
}

th:last-child, td:last-child {
padding-right: 10px;
}

.modal-content {
margin: 2% auto;
padding: 12px;
width: 98%;
}

.form-group input {
padding: 12px 10px;
}

.refresh-btn {
padding: 10px 14px;
font-size: 13px;
}
}

/* 横屏模式优化 */
@media screen and (max-width: 768px) and (orientation: landscape) {
.modal-content {
margin: 2% auto;
max-height: 96vh;
}

.stats {
flex-direction: row;
flex-wrap: wrap;
}

.stat-group {
flex: 1;
min-width: 45%;
}
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
/* 增大所有可点击元素的触摸区域 */
.tab, .btn, .action-dropdown-btn, .action-dropdown-item, 
.stock-dropdown-item, .close {
min-height: 44px;
display: flex;
align-items: center;
justify-content: center;
}

/* 移除悬停效果，使用 active 状态代替 */
.tab:hover, .btn:hover, .action-dropdown-btn:hover {
background: inherit;
}

/* 移除表格行的悬停效果，确保移动端与web版一致 */
tr:hover {
background: inherit;
}

.tab:active {
background: #f0f0f0;
}

.btn-primary:active {
background: #5568d3;
}

.btn-success:active {
background: #059669;
}

.btn-danger:active {
background: #dc2626;
}

.btn-secondary:active {
background: #4b5563;
}

.action-dropdown-btn:active {
background: #5568d3;
}

tr:active {
background: #f0f0f0;
}
}

/* 安全区域适配 (iPhone X 等刘海屏) */
@supports (padding: max(0px)) {
body {
padding-left: env(safe-area-inset-left, 0);
padding-right: env(safe-area-inset-right, 0);
padding-bottom: env(safe-area-inset-bottom, 0);
}

.modal-content {
padding-bottom: max(10px, env(safe-area-inset-bottom));
}
}
