/* ====== FORM COMPONENTS ====== */
label {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select {
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.3s;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.2);
}

.field-description {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ====== BUTTON COMPONENTS ====== */
button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: #00b4d9;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-small {
    padding: 8px 12px;
    font-size: 11px;
}

.btn-warning {
    background: var(--warning);
    color: var(--bg-primary);
}

.btn-warning:hover {
    background: #ff8c00;
}

/* ====== TAB COMPONENTS ====== */
.tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 20px;
    gap: 4px;
}

.tab {
    flex: 1;
    padding: 14px;
    text-align: center;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.tab.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.4);
}

.tab:hover:not(.active) {
    background: var(--bg-tertiary);
}

.tab-content {
    display: none;
    background: var(--bg-secondary);
    padding: 25px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

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

/* ====== ALERT & WARNING COMPONENTS ====== */
.critical-warning {
    background: rgba(255, 71, 87, 0.1);
    border: 2px solid var(--error);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.critical-warning .help-title {
    color: var(--error);
    font-weight: 600;
}

/* ====== WEB LOGIN SECTION VARIANTS ====== */
.web-login-section {
    background: rgba(255, 165, 2, 0.1);
    border: 2px solid var(--warning);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.web-login-title {
    color: var(--warning);
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 10px;
}

.web-login-content {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

.upload-section {
    background: rgba(0, 212, 255, 0.05);
    border-color: var(--accent-primary);
}

.upload-title {
    color: var(--accent-primary);
}

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

.upload-controls input[type="file"] {
    flex: 1;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
}

.upload-status {
    margin-top: 15px;
    padding: 15px;
    border-radius: 6px;
    display: none;
    font-size: 13px;
}

.upload-help {
    margin-top: 15px;
    margin-bottom: 0;
}

.account-section {
    background: rgba(0, 255, 136, 0.05);
    border-color: var(--accent-secondary);
}

.account-title {
    color: var(--accent-secondary);
}

.account-actions {
    margin-bottom: 15px;
}

.account-list {
    max-height: 300px;
    overflow-y: auto;
}

.bulk-status {
    margin-top: 10px;
    display: none;
}

.reload-section {
    background: var(--bg-tertiary);
    border-color: var(--accent-secondary);
}

.reload-title {
    color: var(--accent-secondary);
}

.reload-status {
    margin-top: 15px;
    display: none;
}

.contract-section {
    background: rgba(0, 212, 255, 0.05);
    border-color: var(--accent-primary);
}

.contract-title {
    color: var(--accent-primary);
}

.contract-actions {
    margin-bottom: 15px;
}

.contract-status {
    display: none;
    margin-top: 15px;
    padding: 15px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    font-size: 12px;
}

/* ====== HELP & INFO COMPONENTS ====== */
.help-section {
    background: var(--bg-tertiary);
    border-left: 4px solid var(--accent-secondary);
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.help-title {
    color: var(--accent-secondary);
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 14px;
}

.help-content {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.help-content code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--accent-primary);
    font-family: 'Fira Code', monospace;
}

/* ====== RESULT & STATUS COMPONENTS ====== */
.result-section {
    margin-top: 20px;
    padding: 15px;
    border-radius: 6px;
    display: none;
}

.result-success {
    background: rgba(0, 255, 136, 0.1);
    border: 1px solid var(--success);
}

.result-error {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--error);
}

.result-header {
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.account-result {
    background: var(--bg-tertiary);
    padding: 10px;
    margin: 8px 0;
    border-radius: 4px;
    border-left: 3px solid var(--accent-primary);
}

.account-result.failed {
    border-left-color: var(--error);
}

/* ====== PAYLOAD PREVIEW COMPONENTS ====== */
.payload-section {
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    padding: 15px;
    margin: 20px 0;
}

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

.payload-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
}

.payload-live {
    font-size: 10px;
    color: var(--accent-secondary);
}

pre {
    background: #0d1117;
    color: #00ff88;
    padding: 12px;
    border-radius: 4px;
    font-size: 12px;
    overflow-x: auto;
    margin: 0;
    font-family: 'Fira Code', 'Courier New', monospace;
}

/* ====== SEARCH COMPONENTS ====== */
.search-section {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.search-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.search-input {
    flex: 1;
}

.search-results {
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.search-result-item {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--bg-primary);
}

.search-result-item.selected {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

/* ====== CSV MONITOR COMPONENTS ====== */
.csv-monitor {
    margin-top: 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

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

.csv-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-secondary);
}

.csv-controls {
    display: flex;
    gap: 10px;
}

.csv-table-container {
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.csv-table th {
    background: var(--bg-tertiary);
    padding: 10px;
    text-align: left;
    position: sticky;
    top: 0;
    color: var(--accent-primary);
    font-weight: 600;
}

.csv-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.csv-table tr:hover {
    background: var(--bg-tertiary);
}

.csv-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px;
    font-style: italic;
}

/* ====== LOADING STATES ====== */
.loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--accent-primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   POSITIONS & P&L MODULE STYLES v2.0
   Add these to the end of dashboard/css/components.css
   ========================================================================== */

/* WebSocket Status Indicator */
.ws-status {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 10px;
    transition: all 0.3s;
}

.ws-status.connected {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.ws-status.disconnected {
    background: var(--text-secondary);
}

.ws-status.error {
    background: var(--error);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* P&L Actions Bar */
.pnl-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.report-timestamp {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Order Actions Bar */
.order-actions-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.order-actions {
    display: flex;
    gap: 5px;
}

.order-actions .btn-small {
    padding: 4px 8px;
    font-size: 10px;
}

.order-actions .btn-danger {
    background: var(--error);
    color: white;
}

/* Pending Orders Section */
.pending-orders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-tertiary);
    border-radius: 6px 6px 0 0;
    border-bottom: 1px solid var(--border-color);
}

.pending-orders-header h4 {
    margin: 0;
    color: var(--accent-primary);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
    color: var(--accent-primary);
}

.modal-header .close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
}

.modal-header .close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin: 5px 0;
    font-size: 13px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

/* Modify Results */
.modify-results {
    margin-bottom: 15px;
}

.modify-results .result-item {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 5px;
}

.modify-results .result-item.success {
    background: rgba(0, 255, 136, 0.1);
    border-left: 3px solid var(--success);
}

.modify-results .result-item.error {
    background: rgba(255, 71, 87, 0.1);
    border-left: 3px solid var(--error);
}

.error-detail {
    font-size: 11px;
    color: var(--error);
    margin-top: 5px;
}

/* Alert Rules */
.alert-rules-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}

.alert-rules-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-rule {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.alert-rule.enabled {
    border-color: var(--success);
}

.alert-rule.disabled {
    opacity: 0.6;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    transition: .4s;
    border-radius: 24px;
}

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

input:checked + .slider {
    background-color: var(--success);
}

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

/* Enhanced Buttons */
.btn-small {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 4px;
}

.btn-danger {
    background: var(--error);
    color: white;
    border: none;
    cursor: pointer;
}

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

/* Stats Clickable */
.stat-box {
    cursor: pointer;
    transition: all 0.2s;
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Existing P&L Styles (from previous version) */
.pnl-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.pnl-metric {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid var(--border-color);
}

.pnl-metric.profit {
    border-color: var(--success);
    background: rgba(0, 255, 136, 0.1);
}

.pnl-metric.loss {
    border-color: var(--error);
    background: rgba(255, 71, 87, 0.1);
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
}

.pnl-metric.profit .metric-value {
    color: var(--success);
}

.pnl-metric.loss .metric-value {
    color: var(--error);
}

.metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 5px;
}

.accounts-pnl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

.account-pnl-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
}

.account-pnl-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

/* Close All Section */
.close-all-section {
    background: rgba(255, 71, 87, 0.1);
    border: 2px solid var(--error);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.close-all-title {
    color: var(--error);
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 10px;
}

.close-all-description {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 15px;
}

#closeAllPositionsBtn {
    background: var(--error);
    color: white;
    font-size: 16px;
    padding: 15px 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

#closeAllPositionsBtn:hover:not(:disabled) {
    background: #ff6b7a;
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.4);
    transform: scale(1.02);
}

#closeAllPositionsBtn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* Positions Sections */
.positions-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.positions-section-title {
    color: var(--accent-primary);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Open Positions List */
.open-positions-list {
    max-height: 400px;
    overflow-y: auto;
}

.account-positions-group {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.account-positions-group .account-header {
    background: var(--bg-tertiary);
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.position-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

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

.position-info {
    flex: 1;
}

.position-symbol {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.position-details {
    font-size: 11px;
    color: var(--text-secondary);
}

.position-details .direction {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    margin-right: 8px;
}

.direction.long {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
}

.direction.short {
    background: rgba(255, 71, 87, 0.2);
    color: var(--error);
}

.ltp {
    color: var(--accent-primary);
    margin-left: 10px;
}

.position-pnl {
    text-align: right;
    min-width: 100px;
}

.pnl-amount {
    font-size: 16px;
    font-weight: 700;
}

.position-pnl.profit .pnl-amount {
    color: var(--success);
}

.position-pnl.loss .pnl-amount {
    color: var(--error);
}

.pnl-label {
    font-size: 10px;
    color: var(--text-secondary);
}

/* Order Table Enhancements */
.orders-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.orders-table th {
    background: var(--bg-tertiary);
    padding: 10px;
    text-align: left;
    font-weight: 600;
    color: var(--accent-primary);
    position: sticky;
    top: 0;
}

.orders-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.orders-table tr:hover {
    background: var(--bg-tertiary);
}

.status-badge {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.complete {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
}

.status-badge.pending,
.status-badge.open,
.status-badge.amo {
    background: rgba(255, 165, 2, 0.2);
    color: var(--warning);
}

.status-badge.rejected {
    background: rgba(255, 71, 87, 0.2);
    color: var(--error);
}

.status-badge.cancelled {
    background: rgba(139, 149, 167, 0.2);
    color: var(--text-secondary);
}

.rejection-reason {
    background: rgba(255, 71, 87, 0.1);
    color: var(--error);
    font-size: 10px;
    font-style: italic;
}

.rejection-reason td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

/* ================================================================================================ */
/* Enhanced Search Results */
/* ================================================================================================ */
/* Search Results Header */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary);
}

.search-results-header .sort-hint {
    font-style: italic;
    opacity: 0.7;
}

/* Enhanced Search Result Item */
.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

.search-result-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(3px);
}

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

/* Instrument Key Display */
.instrument-key {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 13px;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Highlight matching text */
.search-highlight {
    background: rgba(255, 165, 2, 0.3);
    color: var(--accent-secondary);
    font-weight: 700;
    padding: 0 2px;
    border-radius: 2px;
}

/* Meta Information */
.instrument-meta {
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.meta-symbol {
    color: var(--text-primary);
    font-weight: 500;
}

.meta-separator {
    color: var(--text-secondary);
    opacity: 0.5;
}

.meta-exchange-nse { color: #00ff88; }
.meta-exchange-nfo { color: #ffa502; }
.meta-exchange-mcx { color: #ff6b81; }

.meta-type {
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 9px;
}

.meta-type-ce { 
    background: rgba(0, 255, 136, 0.15); 
    color: #00ff88; 
}

.meta-type-pe { 
    background: rgba(255, 71, 87, 0.15); 
    color: #ff4757; 
}

.meta-type-fut { 
    background: rgba(255, 165, 2, 0.15); 
    color: #ffa502; 
}

/* Details Row */
.instrument-details {
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.detail-item {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 3px;
}

.detail-token {
    color: var(--text-secondary);
    opacity: 0.5;
    font-family: monospace;
    font-size: 9px;
}

/* Select Button */
.btn-select {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.search-result-item:hover .btn-select {
    opacity: 1;
}

.btn-select:hover {
    background: var(--accent-secondary);
    transform: scale(1.05);
}


/* Enhanced WebSocket Status Indicator */
.ws-status {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-left: 10px;
    font-size: 12px;
    line-height: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.ws-status.connected {
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
    color: var(--success);
}

.ws-status.connecting {
    background: var(--warning);
    color: var(--warning);
    animation: pulse 1s infinite;
}

.ws-status.disconnected {
    background: var(--text-secondary);
    color: var(--text-secondary);
    opacity: 0.5;
}

.ws-status.reconnecting {
    background: var(--warning);
    color: var(--warning);
    animation: pulse 1.5s infinite;
}

.ws-status.error {
    background: var(--error);
    color: var(--error);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}


/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    overflow: hidden;
    transition: all var(--transition-base);
}

.card:hover {
    border-color: var(--border-secondary);
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: var(--space-lg);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    outline: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-primary);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--error-alpha);
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: var(--error);
    color: white;
}

.btn-large {
    padding: var(--space-md) var(--space-xl);
    font-size: var(--text-base);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    flex: 1;
}

.form-group label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    padding: var(--space-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: var(--text-base);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-alpha);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 4px;
    border: 1px solid var(--border-primary);
}

.segmented-control input {
    display: none;
}

.segment-btn {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    text-align: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 600;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.segment-btn.buy {
    color: var(--success);
}

.segment-btn.sell {
    color: var(--error);
}

.segmented-control input:checked + .segment-btn {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.segmented-control input:checked + .segment-btn.buy {
    background: var(--success-alpha);
    color: var(--success);
}

.segmented-control input:checked + .segment-btn.sell {
    background: var(--error-alpha);
    color: var(--error);
}

/* Search Input */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper i {
    position: absolute;
    left: var(--space-md);
    color: var(--text-muted);
}

.search-input-wrapper input {
    width: 100%;
    padding: var(--space-md) var(--space-md) var(--space-md) 40px;
}


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

/* Quantity Input */
.quantity-input {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-primary);
}

.qty-btn {
    width: 40px;
    height: 44px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    font-size: var(--text-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.qty-btn:hover {
    background: var(--border-primary);
}

.quantity-input input {
    flex: 1;
    border: none;
    text-align: center;
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: 600;
    background: transparent;
    color: var(--text-primary);
    outline: none;
}

.lot-info {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.data-table th {
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}

.data-table td {
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: var(--bg-secondary);
}

/* P&L Display */
.pnl-display {
    padding: var(--space-xl);
}

.pnl-main {
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
}

.pnl-main.positive {
    color: var(--success);
}

.pnl-main.negative {
    color: var(--error);
}

.pnl-breakdown {
    display: flex;
    gap: var(--space-xl);
}

.pnl-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.pnl-item .label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
}

.pnl-item .value {
    font-family: var(--font-mono);
    font-size: var(--text-lg);
    font-weight: 600;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
    text-align: center;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    pointer-events: none;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-md) var(--space-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 300px;
    pointer-events: all;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

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

/* Live Badge */
.live-badge {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: var(--radius-full);
    animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}


/* Enhanced Search Results */

.symbol-group-header {
    background: var(--bg-tertiary);
    padding: 8px 15px;
    margin-top: 10px;
    border-left: 3px solid var(--accent-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-symbol {
    font-weight: 700;
    color: var(--accent-primary);
    font-size: 13px;
}

.group-count {
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 10px;
}

.search-result-item {
    position: relative;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

.search-result-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(3px);
}

.search-result-item.fut {
    border-left: 3px solid #ffa502;
}

.search-result-item.ce {
    border-left: 3px solid #00ff88;
}

.search-result-item.pe {
    border-left: 3px solid #ff4757;
}

.result-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.type-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.meta-expiry {
    color: var(--accent-secondary);
    font-weight: 600;
}

.filter-hints {
    font-size: 11px;
    color: var(--text-secondary);
}

.filter-hints .hint {
    font-style: italic;
}


/* ==========================================================================
   MASTERFILE MODULE STYLES v1.0
   ========================================================================== */

.masterfile-container {
    padding: 20px;
}

/* Header */
.mf-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.mf-title-section h2 {
    margin: 0 0 5px 0;
    color: var(--accent-primary);
    font-size: 24px;
}

.mf-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.mf-actions-header {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Stats Grid */
.mf-stats-container {
    margin-bottom: 25px;
}

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

.mf-stat-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.mf-stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

.mf-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.mf-stat-card.positive .mf-stat-value {
    color: var(--success);
}

.mf-stat-card.negative .mf-stat-value {
    color: var(--error);
}

.mf-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filters */
.mf-filters {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    flex-wrap: wrap;
}

.mf-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mf-filter-group label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.mf-filter-input {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    min-width: 120px;
}

.mf-filter-checkbox {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.mf-filter-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.mf-filter-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.mf-last-update {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Table */
.mf-table-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.mf-table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

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

.mf-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.mf-table th {
    background: var(--bg-tertiary);
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: var(--accent-primary);
    border-bottom: 2px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.mf-table th.sortable:hover {
    background: var(--border-color);
}

.mf-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.mf-row {
    transition: background 0.2s;
}

.mf-row:hover {
    background: var(--bg-tertiary);
}

.mf-row.active {
    border-left: 3px solid var(--success);
}

.mf-row.inactive {
    border-left: 3px solid var(--warning);
}

.mf-row.offline {
    border-left: 3px solid var(--error);
    opacity: 0.7;
}

/* Cell Styling */
.mf-table .mono {
    font-family: 'Fira Code', monospace;
    font-size: 12px;
}

.mf-table .positive {
    color: var(--success);
    font-weight: 600;
}

.mf-table .negative {
    color: var(--error);
    font-weight: 600;
}

/* Badges */
.mf-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.mf-badge.enabled {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
}

.mf-badge.disabled {
    background: rgba(139, 149, 167, 0.2);
    color: var(--text-secondary);
}

.mf-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.mf-status.active {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
}

.mf-status.inactive {
    background: rgba(255, 165, 2, 0.2);
    color: var(--warning);
}

.mf-status.offline {
    background: rgba(255, 71, 87, 0.2);
    color: var(--error);
}

/* Action Buttons */
.mf-actions {
    display: flex;
    gap: 5px;
}

.mf-btn-icon {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mf-btn-icon:hover {
    background: var(--accent-primary);
    transform: scale(1.1);
}

/* Bulk Actions */
.mf-bulk-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
}

/* Modal Enhancements */
.mf-modal .modal-content {
    max-width: 600px;
}

.mf-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.mf-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
}

.mf-detail-item.highlight {
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid var(--accent-primary);
}

.mf-detail-item label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mf-detail-item value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.mf-detail-item value.positive {
    color: var(--success);
}

.mf-detail-item value.negative {
    color: var(--error);
}

.mf-detail-item value.active {
    color: var(--success);
}

.mf-detail-item value.inactive {
    color: var(--warning);
}

/* Loading & Empty States */
.mf-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.mf-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.mf-error {
    text-align: center;
    padding: 40px;
    color: var(--error);
}

/* Spinning Animation for Refresh */
.spinning {
    animation: spin 1s linear infinite;
}

/* Responsive */
@media (max-width: 768px) {
    .mf-header {
        flex-direction: column;
    }
    
    .mf-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .mf-filter-actions {
        margin-left: 0;
        justify-content: flex-end;
    }
    
    .mf-detail-grid {
        grid-template-columns: 1fr;
    }
    
    .mf-table th,
    .mf-table td {
        padding: 8px 10px;
        font-size: 12px;
    }
}