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

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

/* Login Screen */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
}

.login-box {
    background: white;
    border-radius: 16px;
    padding: 48px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 420px;
    width: 100%;
}

.login-box h1 {
    font-size: 32px;
    color: #1a202c;
    margin-bottom: 8px;
}

.login-subtitle {
    color: #718096;
    font-size: 16px;
    margin-bottom: 24px;
}

.login-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, #e2e8f0, transparent);
    margin: 24px 0;
}

#login-form {
    width: 100%;
}

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

.form-group label {
    display: block;
    color: #4a5568;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

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

.form-group input:disabled {
    background: #f7fafc;
    color: #a0aec0;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 8px;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.error-message {
    color: #e53e3e;
    font-size: 13px;
    margin-top: 8px;
    margin-bottom: 8px;
    min-height: 20px;
    font-weight: 500;
}

.login-note {
    color: #e53e3e;
    font-size: 13px;
    font-weight: 500;
    background: #fff5f5;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #feb2b2;
    margin-top: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-signout {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-signout:hover {
    background: #c53030;
}

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

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

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

h1 {
    font-size: 28px;
    color: #1a202c;
    font-weight: 700;
}

.account-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-selector label {
    font-weight: 600;
    color: #4a5568;
}

.account-selector select {
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    min-width: 250px;
    cursor: pointer;
}

.btn-icon {
    padding: 8px 12px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #edf2f7;
}

.account-summary {
    display: flex;
    gap: 30px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
}

.metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric .label {
    font-size: 12px;
    color: #718096;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric .value {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
}

main {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

.badge {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.btn-clear-filter {
    padding: 6px 12px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    margin-left: auto;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: #f7fafc;
}

th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

td {
    padding: 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    color: #2d3748;
}

tbody tr:hover {
    background: #f8fafc;
}

.profit-positive {
    color: #22c55e;
    font-weight: 600;
}

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

.comment-cell, .remark-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    color: #64748b;
}

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

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

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

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a202c;
}

.close-modal {
    font-size: 28px;
    color: #a0aec0;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: #4a5568;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
    max-height: calc(90vh - 145px);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.btn-cancel {
    padding: 10px 20px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
}

.btn-cancel:hover {
    background: #edf2f7;
}

.btn-save {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

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

/* Group Action Buttons */
.group-action-cell {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.btn-close-all {
    padding: 4px 8px;
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.btn-close-all:hover {
    background: #fed7d7;
    border-color: #fc8181;
}

.btn-close-profit {
    padding: 4px 8px;
    background: #f0fff4;
    color: #276749;
    border: 1px solid #9ae6b4;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.btn-close-profit:hover {
    background: #c6f6d5;
    border-color: #68d391;
}

/* Auto SL Rules Section */
.sl-rules-divider {
    border-top: 1px solid #e2e8f0;
    margin: 16px 0 14px;
}

.sl-rules-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}

.sl-rules-header h4 {
    font-size: 13px;
    font-weight: 600;
    color: #2d3748;
    white-space: nowrap;
}

.sl-rules-hint {
    font-size: 11px;
    color: #a0aec0;
}

.sl-rules-empty {
    font-size: 12px;
    color: #a0aec0;
    text-align: center;
    padding: 8px 0;
}

.sl-rule-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f7fafc;
    border-radius: 6px;
    margin-bottom: 5px;
    font-size: 12px;
}

.sl-rule-row.sl-rule-triggered {
    background: #f0fff4;
    opacity: 0.8;
}

.sl-rule-trigger {
    font-weight: 600;
    color: #2d3748;
    min-width: 110px;
}

.sl-rule-arrow {
    color: #a0aec0;
}

.sl-rule-newsl {
    color: #e53e3e;
    font-weight: 600;
    flex: 1;
}

.btn-sl-rules {
    display: inline-block;
    margin-left: 4px;
    padding: 1px 5px;
    background: none;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    font-size: 11px;
    color: #718096;
    cursor: pointer;
    vertical-align: middle;
    line-height: 1.4;
}
.btn-sl-rules:hover {
    background: #edf2f7;
    border-color: #a0aec0;
    color: #2d3748;
}

.sl-rules-count-badge {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #ebf8ff;
    color: #2b6cb0;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    cursor: default;
}

.sl-rule-status {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

.sl-rule-status.active {
    background: #ebf8ff;
    color: #2b6cb0;
}

.sl-rule-status.triggered {
    background: #f0fff4;
    color: #276749;
}

.btn-delete-rule {
    background: none;
    border: none;
    color: #a0aec0;
    font-size: 16px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.btn-delete-rule:hover {
    color: #e53e3e;
}

.sl-rule-add-row {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
    gap: 8px;
    margin-top: 8px;
}

.sl-rule-btn-group {
    margin-bottom: 20px;
}

.btn-add-rule {
    width: 100%;
    padding: 10px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.empty-state h2 {
    font-size: 24px;
    color: #2d3748;
    margin-bottom: 10px;
}

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

/* Action Buttons */
.btn-action {
    background: #667eea;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 12px;
}

.btn-action:hover {
    background: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-note {
    background: #edf2f7;
    border-left: 4px solid #667eea;
    padding: 12px;
    border-radius: 4px;
    font-size: 14px;
    color: #4a5568;
    margin-top: 16px;
}

.form-note strong {
    color: #2d3748;
}

select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Waiting Sync Panel */
#waiting-sync-panel {
    border-left: 4px solid #f59e0b;
}

#waiting-sync-panel .panel-header h2 {
    color: #f59e0b;
}

.badge-warning {
    background: #f59e0b;
}

.status-waiting {
    display: inline-block;
    padding: 4px 12px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
}
