:root {
    --bg-color: #f5f5f5;
    --text-color: #1a1a1a;
    --header-color: #00529B;
    --table-bg: #fff;
    --table-border-color: #d0d0d0;
    --table-header-bg: #e8e8e8;
    --button-bg: #007BFF;
    --button-hover-bg: #0056b3;
    --tab-hover-bg: #e8e8e8;
    --tab-active-color: #007BFF;
    --section-bg: #fff;
    --section-border-color: #d0d0d0;
    --summary-bg: #e8e8e8;
}

body[data-theme='dark'] {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --header-color: #64b5f6;
    --table-bg: #1e1e1e;
    --table-border-color: #444;
    --table-header-bg: #2c2c2c;
    --button-bg: #1976d2;
    --button-hover-bg: #1565c0;
    --tab-hover-bg: #333;
    --tab-active-color: #64b5f6;
    --section-bg: #1e1e1e;
    --section-border-color: #444;
    --summary-bg: #2c2c2c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 20px;
    line-height: 1.6;
    font-size: 18px;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
}

h1 {
    text-align: center;
    color: var(--header-color);
    margin-bottom: 20px;
}

.main-container {
    width: 100%;
    max-width: 100%;
    padding: 0;
    overflow-x: hidden;
}

.section {
    background: var(--section-bg);
    border: 1px solid var(--section-border-color);
    padding: 20px;
    border-radius: 8px;
    flex: 1;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

button {
    background-color: var(--button-bg);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

button:hover {
    background-color: var(--button-hover-bg);
}

input[type="date"] {
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #c0c0c0;
    background-color: #fff;
    color: var(--text-color);
    font-size: 16px;
}

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

th, td {
    border: 1px solid var(--table-border-color);
    padding: 12px 15px;
    text-align: left;
    white-space: nowrap;
}

th {
    background-color: var(--table-header-bg);
}

.profit {
    color: #26a69a; /* Green */
}

.loss {
    color: #ef5350; /* Red */
}

.summary-row {
    font-weight: bold;
    background-color: var(--summary-bg);
}

.summary-row td {
    border-top: 2px solid #ddd;
    border-bottom: 2px solid #ddd;
}

.refresh-status {
    margin: 10px 0;
    font-size: 0.9em;
    color: #555;
    font-weight: 500;
}

.tab-container {
    width: 100%;
}

.tab-header {
    display: flex;
    border-bottom: 1px solid #ccc;
}

.tab-header button {
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 14px 16px;
    transition: all 0.3s ease;
    font-size: 16px;
    color: var(--text-color);
    border-bottom: 3px solid transparent;
}

.tab-header button:hover {
    background-color: var(--tab-hover-bg);
}

.tab-header button.active {
    color: var(--tab-active-color);
    border-bottom-color: var(--tab-active-color);
}

.tab-content {
    display: none;
    padding: 20px 12px;
    border-top: none;
}

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

.summary-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    margin-bottom: 20px;
    background-color: var(--section-bg);
    border-radius: 8px;
    border: 1px solid var(--section-border-color);
}

.summary-item {
    background-color: var(--summary-bg);
    border: 1px solid var(--section-border-color);
    border-radius: 8px;
    padding: 15px;
    flex: 1 1 200px; /* Flex-grow, flex-shrink, flex-basis */
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.summary-label {
    font-size: 0.9em;
    color: #555;
    font-weight: 500;
    margin-bottom: 5px;
}

.summary-value {
    font-size: 1.2em;
    font-weight: bold;
}

.total-summary {
    font-weight: bold;
    border-top: 2px solid var(--section-border-color);
    padding-top: 15px;
    margin-top: 10px;
    width: 100%;
    text-align: center;
}

.table-container {
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--table-border-color);
    border-radius: 8px;
}

.table-container thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background-color: var(--table-header-bg);
}

#theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background-color: var(--button-bg);
    color: white;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    transition: background-color 0.3s;
}

#theme-toggle:hover {
    background-color: var(--button-hover-bg);
}

#settings-toggle {
    position: fixed;
    top: 20px;
    right: 90px;
    z-index: 1000;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background-color: var(--button-bg);
    color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    transition: background-color 0.3s;
}

#settings-toggle:hover {
    background-color: var(--button-hover-bg);
}

@media (max-width: 768px) {
    .summary-container {
        flex-direction: column;
    }
}

/* 止损配置样式 */
.stop-loss-config {
    background-color: var(--summary-bg);
    border: 1px solid var(--section-border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.stop-loss-config h3 {
    margin: 0 0 15px 0;
    color: var(--header-color);
    font-size: 18px;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-item label {
    font-weight: 500;
    min-width: 80px;
}

.config-item input {
    padding: 6px 10px;
    border: 1px solid #c0c0c0;
    border-radius: 4px;
    background-color: #fff;
    color: var(--text-color);
    font-size: 14px;
    width: 120px;
}

.config-item .unit {
    color: #666;
    font-weight: 500;
}

.config-buttons {
    display: flex;
    gap: 10px;
}

.config-buttons button {
    padding: 6px 15px;
    font-size: 14px;
}

.config-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.config-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.config-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

body[data-theme='dark'] .config-status.success {
    background-color: #1e4620;
    color: #7dff8f;
    border-color: #2d5f2f;
}

body[data-theme='dark'] .config-status.error {
    background-color: #4a1e1e;
    color: #ff7d7d;
    border-color: #5f2d2d;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--section-bg);
    margin: 3% auto;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideDown 0.3s;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--section-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h2 {
    margin: 0;
    color: var(--header-color);
    font-size: 20px;
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* 自定义滚动条样式 */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--summary-bg);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--table-border-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--button-bg);
}

.close {
    color: var(--text-color);
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s;
    line-height: 1;
}

.close:hover {
    opacity: 1;
}

/* 优化止损配置在弹窗中的样式 */
.modal .stop-loss-config {
    background-color: transparent;
    border: none;
    padding: 0;
    margin: 0;
}

/* 配置区块 */
.config-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--section-border-color);
}

.config-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.config-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: var(--text-color);
    font-weight: 600;
}

/* 开关样式 */
.config-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 26px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 16px;
    font-weight: 600;
}

/* 配置网格 */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 600px) {
    .config-grid {
        grid-template-columns: 1fr;
    }
}

.config-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

.config-field small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

.input-group {
    display: flex;
    align-items: center;
    border: 1px solid var(--table-border-color);
    border-radius: 6px;
    overflow: hidden;
    background-color: var(--table-bg);
}

.input-group input {
    flex: 1;
    border: none;
    padding: 10px 12px;
    background-color: transparent;
    color: var(--text-color);
    font-size: 14px;
}

.input-group input:focus {
    outline: none;
}

.input-suffix {
    padding: 0 12px;
    color: #666;
    font-size: 14px;
    background-color: var(--summary-bg);
}

.save-button {
    width: 100%;
    padding: 12px;
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

.save-button:hover {
    background-color: var(--button-hover-bg);
}

/* 状态网格 */
.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

@media (max-width: 600px) {
    .status-grid {
        grid-template-columns: 1fr;
    }
}

.status-item {
    background-color: var(--summary-bg);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.status-label {
    display: block;
    font-size: 12px;
    color: #666;
    font-weight: 500;
    margin-bottom: 8px;
}

.status-value {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

/* 设置标签页 */
.settings-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid var(--section-border-color);
}

.settings-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    opacity: 0.6;
}

.settings-tab:hover {
    opacity: 0.8;
}

.settings-tab.active {
    opacity: 1;
    border-bottom-color: var(--button-bg);
    color: var(--button-bg);
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

/* DDDD 配置样式 */
.dddd-status {
    background-color: var(--summary-bg);
    padding: 15px;
    border-radius: 8px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.status-row:last-child {
    margin-bottom: 0;
}

.status-row .status-label {
    font-weight: 500;
    min-width: 80px;
}

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

.status-badge.status-valid {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.status-invalid {
    background-color: #f8d7da;
    color: #721c24;
}

.status-badge.status-disabled {
    background-color: #e2e3e5;
    color: #6c757d;
}

body[data-theme='dark'] .status-badge.status-valid {
    background-color: #1e4620;
    color: #7dff8f;
}

body[data-theme='dark'] .status-badge.status-invalid {
    background-color: #4a1e1e;
    color: #ff7d7d;
}

body[data-theme='dark'] .status-badge.status-disabled {
    background-color: #2c2c2c;
    color: #adb5bd;
}

.config-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--table-border-color);
    border-radius: 6px;
    background-color: var(--table-bg);
    color: var(--text-color);
    font-size: 14px;
    font-family: monospace;
    resize: vertical;
}

.config-field textarea:focus {
    outline: none;
    border-color: var(--button-bg);
}

/* Cookie 过期时间样式 */
.expiry-normal {
    color: #28a745;
}

.expiry-warning {
    color: #ffc107;
    font-weight: 600;
}

.expiry-expired {
    color: #dc3545;
    font-weight: 600;
}

body[data-theme='dark'] .expiry-normal {
    color: #7dff8f;
}

body[data-theme='dark'] .expiry-warning {
    color: #ffd966;
}

body[data-theme='dark'] .expiry-expired {
    color: #ff7d7d;
}

/* 登录弹窗样式 */
#login-modal {
    background-color: var(--section-bg); /* 完全不透明 */
}

#login-modal .modal-content {
    max-width: 400px;
}

#login-modal .modal-header {
    background: linear-gradient(135deg, var(--button-bg) 0%, var(--button-hover-bg) 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

#login-modal .modal-header h2 {
    color: white;
}

#login-modal .config-field {
    margin-bottom: 20px;
}

#login-modal .config-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

#login-modal .config-field input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--table-border-color);
    border-radius: 8px;
    background-color: var(--table-bg);
    color: var(--text-color);
    font-size: 15px;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

#login-modal .config-field input[type="password"]:focus {
    outline: none;
    border-color: var(--button-bg);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#login-modal .save-button {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 10px;
}