/* Settings Modal Styles */
.settings-trigger {
    position: fixed;
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    background: rgba(39, 39, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(113, 113, 122, 0.3);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 999;
    box-shadow: 0 0 20px rgba(161, 161, 170, 0.2);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(161, 161, 170, 0.2);
    }

    50% {
        box-shadow: 0 0 30px rgba(161, 161, 170, 0.4);
    }
}

.settings-trigger:hover {
    transform: rotate(90deg) scale(1.1);
}

.settings-trigger svg {
    width: 24px;
    height: 24px;
    fill: #a1a1aa;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    /* Higher than context menu */
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-container {
    background: rgba(24, 24, 27, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    overflow: hidden;
    border: 1px solid rgba(82, 82, 91, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s;
    box-shadow: 0 0 60px rgba(113, 113, 122, 0.2);
}

.modal-overlay.active .modal-container {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: rgba(39, 39, 42, 0.8);
    border: 1px solid rgba(161, 161, 170, 0.3);
    border-radius: 8px;
    cursor: pointer;
    color: #9ca3af;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.3s;
}

.modal-close:hover {
    background: rgba(220, 38, 38, 0.8);
    color: #fff;
    transform: rotate(90deg);
}

.container-settings {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: 240px;
    background: rgba(39, 39, 42, 0.6);
    backdrop-filter: blur(10px);
    padding: 32px 0;
    border-right: 1px solid rgba(161, 161, 170, 0.2);
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 600;
    padding: 0 24px 24px;
    color: #fff;
    text-shadow: 0 0 10px rgba(161, 161, 170, 0.5);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav button {
    display: block;
    width: 100%;
    padding: 10px 24px;
    color: #9ca3af;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
    font-family: inherit;
}

.sidebar-nav button:hover {
    color: #e0e0e0;
    background: rgba(161, 161, 170, 0.05);
}

.sidebar-nav button.active {
    color: #a1a1aa;
    background: rgba(161, 161, 170, 0.1);
    border-left-color: #71717a;
    text-shadow: 0 0 10px rgba(161, 161, 170, 0.5);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-section {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    animation: fadeIn 0.3s ease-in;
}

.content-section.active {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-title {
    font-size: 28px;
    font-weight: 600;
    padding: 48px 64px 24px;
    color: #fff;
    text-shadow: 0 0 20px rgba(161, 161, 170, 0.6);
    flex-shrink: 0;
    background: rgba(24, 24, 27, 0.95);
    position: relative;
    margin: 0;
}

.page-title::after {
    content: '';
    position: absolute;
    bottom: 10px;
    left: 64px;
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, #71717a, transparent);
    box-shadow: 0 0 10px rgba(161, 161, 170, 0.6);
}

.sections-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 0 64px 48px;
}

.sections-wrapper::-webkit-scrollbar {
    width: 8px;
}

.sections-wrapper::-webkit-scrollbar-thumb {
    background: rgba(161, 161, 170, 0.3);
    border-radius: 4px;
}

.sections-wrapper>*:first-child {
    margin-top: 16px;
}

.section {
    background: rgba(39, 39, 42, 0.4);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 24px;
    border: 1px solid rgba(161, 161, 170, 0.2);
    transition: all 0.3s;
}

.section:hover {
    border-color: rgba(161, 161, 170, 0.4);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #fff;
    margin-top: 0;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 24px;
}

.section-title-row .section-title {
    margin-bottom: 0;
}

.section-info {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none;
}

.section-info-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(161, 161, 170, 0.5);
    color: #c9c9cf;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    background: rgba(39, 39, 42, 0.7);
}

.section-info-tooltip {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    max-width: min(280px, calc(100vw - 120px));
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(161, 161, 170, 0.3);
    background: rgba(24, 24, 27, 0.96);
    color: #d6d6dc;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 20;
}

.section-info:hover .section-info-tooltip,
.section-info:focus-within .section-info-tooltip {
    opacity: 1;
    visibility: visible;
}

.field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(161, 161, 170, 0.1);
}

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

.field-info {
    flex: 1;
}

.field-label {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 4px;
}

.field-description {
    font-size: 13px;
    color: #6b7280;
}

.field-value {
    font-size: 14px;
    color: #9ca3af;
}

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

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #e0e0e0;
    margin-bottom: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(24, 24, 27, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(161, 161, 170, 0.2);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #71717a;
    background: rgba(39, 39, 42, 0.8);
    box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.1);
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0;
    cursor: pointer;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #71717a;
}

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

.btn-primary {
    background: linear-gradient(135deg, #71717a, #52525b);
    color: #fff;
    box-shadow: 0 0 20px rgba(161, 161, 170, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #52525b, #3f3f46);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(52, 52, 57, 0.6);
    color: #fff;
    border: 1px solid rgba(161, 161, 170, 0.3);
}

.btn-secondary:hover {
    background: rgba(52, 52, 57, 0.8);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: #a1a1aa;
    border: 1px solid rgba(161, 161, 170, 0.4);
}

.btn-outline:hover {
    background: rgba(161, 161, 170, 0.1);
    transform: translateY(-2px);
}

.btn-group {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: rgba(52, 52, 57, 0.6);
    border: 1px solid rgba(161, 161, 170, 0.2);
    border-radius: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.toggle-switch.active {
    background: linear-gradient(135deg, #71717a, #52525b);
    box-shadow: 0 0 15px rgba(161, 161, 170, 0.4);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    top: 1px;
    left: 1px;
    transition: all 0.3s;
}

.toggle-switch.active::after {
    transform: translateX(22px);
}

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

.badge-success {
    background: rgba(20, 83, 45, 0.3);
    border-color: rgba(22, 163, 74, 0.5);
    color: #86efac;
}

.badge-danger {
    background: rgba(127, 29, 29, 0.3);
    border-color: rgba(220, 38, 38, 0.5);
    color: #fca5a5;
}

.badge-warning {
    background: rgba(113, 63, 18, 0.3);
    border-color: rgba(245, 158, 11, 0.5);
    color: #fcd34d;
}

.badge-info {
    background: rgba(63, 63, 70, 0.3);
    border-color: rgba(161, 161, 170, 0.5);
    color: #a1a1aa;
}

.alert {
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid;
    backdrop-filter: blur(10px);
}

.alert-info {
    background: rgba(12, 30, 46, 0.6);
    border-color: #71717a;
    color: #d4d4d8;
}

.alert-warning {
    background: rgba(31, 26, 13, 0.6);
    border-color: #f59e0b;
    color: #fcd34d;
}

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

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(161, 161, 170, 0.1);
}

th {
    background: rgba(39, 39, 42, 0.6);
    color: #a1a1aa;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
}

tr:hover {
    background: rgba(161, 161, 170, 0.05);
}

.save-notification {
    position: fixed;
    top: 20px;
    right: 80px;
    background: rgba(20, 83, 45, 0.9);
    color: #86efac;
    padding: 12px 20px;
    border-radius: 8px;
    border: 1px solid rgba(22, 163, 74, 0.5);
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.3);
    z-index: 1001;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    pointer-events: none;
}

.save-notification.show {
    opacity: 1;
    transform: translateY(0);
}

/* ---------------------------------------------------------------------------
   Max notional cap input (global planner controls bar)
   --------------------------------------------------------------------------- */

.planner-global-group-cap {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
}

.planner-global-cap-label {
    color: #8f96a3;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.planner-global-cap-input {
    width: 86px;
    padding: 5px 7px;
    border: 1px solid #2a2e39;
    border-radius: 5px;
    background: #0f131d;
    color: #d1d4dc;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.planner-global-cap-input:focus {
    outline: none;
    border-color: #2962ff;
}

.planner-global-cap-input::placeholder {
    color: #5c6470;
}

/* ---------------------------------------------------------------------------
   Exchange connection panel
   --------------------------------------------------------------------------- */

.exchange-panel-backdrop {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(6, 9, 15, 0.72);
}

.exchange-panel {
    width: min(560px, 92vw);
    max-height: 86vh;
    overflow-y: auto;
    border: 1px solid #2a2e39;
    border-radius: 12px;
    background: #131722;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    color: #d1d4dc;
}

.exchange-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid #1e222d;
}

.exchange-panel-title {
    font-size: 14px;
    font-weight: 700;
    color: #f2f5ff;
}

.exchange-panel-close {
    border: 0;
    background: transparent;
    color: #8f96a3;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.exchange-panel-close:hover { color: #d1d4dc; }

.exchange-panel-warning {
    margin: 12px 16px 4px;
    padding: 9px 11px;
    border: 1px solid #5a4326;
    border-radius: 7px;
    background: #241c10;
    color: #e8c07d;
    font-size: 11px;
    line-height: 1.45;
}

.exchange-panel-body { padding: 8px 16px 16px; }

.exchange-account {
    padding: 12px 0;
    border-bottom: 1px solid #1e222d;
}

.exchange-account:last-child { border-bottom: 0; }

.exchange-account-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.exchange-account-name { font-size: 12px; font-weight: 700; color: #f2f5ff; }

.exchange-account-status {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #8f96a3;
}

.exchange-account-status.is-connected { color: #26a69a; }

.exchange-input {
    width: 100%;
    margin-bottom: 6px;
    padding: 7px 9px;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    background: #0f131d;
    color: #d1d4dc;
    font-size: 12px;
}

.exchange-input:focus { outline: none; border-color: #2962ff; }

.exchange-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 14px;
    color: #8f96a3;
    font-size: 11px;
    cursor: pointer;
}

.exchange-account-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.exchange-btn {
    padding: 6px 11px;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    background: #1b2030;
    color: #d1d4dc;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.exchange-btn:hover:not(:disabled) { background: #22293c; }
.exchange-btn:disabled { opacity: 0.5; cursor: default; }

.exchange-account-message {
    margin-top: 8px;
    min-height: 14px;
    font-size: 11px;
    color: #8f96a3;
}

.exchange-account-message.tone-ok { color: #26a69a; }
.exchange-account-message.tone-error { color: #ef5350; }

.planner-global-connect-btn {
    margin-left: 4px;
    padding: 4px 8px;
    border: 1px solid #2a2e39;
    border-radius: 5px;
    background: #1b2030;
    color: #d1d4dc;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.planner-global-connect-btn:hover { background: #22293c; }

/* ---------------------------------------------------------------------------
   Placement refusal banner: shown when the backend cannot accept new orders
   --------------------------------------------------------------------------- */

.placement-refused-banner {
    position: fixed;
    top: 14px;
    left: 50%;
    z-index: 5000;
    padding: 9px 16px;
    border: 1px solid #7a3b3b;
    border-radius: 8px;
    background: #2a1618;
    color: #ffb4ae;
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -12px);
    transition: opacity 140ms ease, transform 140ms ease;
}

.placement-refused-banner.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
