.qfmc-widget,
.qfmc-price-table-widget {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    margin: 24px 0;
    padding: 18px;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    color: #111827;
    font-family: inherit;
}

.qfmc-widget *,
.qfmc-widget *::before,
.qfmc-widget *::after,
.qfmc-price-table-widget *,
.qfmc-price-table-widget *::before,
.qfmc-price-table-widget *::after {
    box-sizing: border-box;
}

.qfmc-form {
    display: grid;
    grid-template-columns: 1fr 1.25fr .9fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 14px;
}

.qfmc-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.qfmc-field label {
    font-size: 13px;
    font-weight: 700;
    color: #374151;
}

.qfmc-field input,
.qfmc-field select {
    width: 100%;
    min-height: 42px;
    border: 1px solid #d1d5db;
    border-radius: 12px;
    padding: 9px 12px;
    background: #ffffff;
    color: #111827;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.qfmc-field input:focus,
.qfmc-field select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.qfmc-submit,
.qfmc-table-refresh {
    min-height: 42px;
    border: 0;
    border-radius: 12px;
    padding: 10px 18px;
    background: #111827;
    color: #ffffff;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    white-space: nowrap;
}

.qfmc-submit:hover,
.qfmc-table-refresh:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.qfmc-status,
.qfmc-table-status {
    min-height: 24px;
    margin: 6px 0 10px;
    font-size: 13px;
    line-height: 1.8;
    color: #4b5563;
}

.qfmc-status--loading,
.qfmc-table-status--loading {
    color: #2563eb;
}

.qfmc-status--success,
.qfmc-table-status--success {
    color: #047857;
}

.qfmc-status--error,
.qfmc-table-status--error {
    color: #b91c1c;
}

.qfmc-chart {
    position: relative;
    width: 100%;
    min-height: 320px;
    border: 1px solid #eef2f7;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
}

.qfmc-chart--loading::after,
.qfmc-table--loading .qfmc-table-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.35);
    pointer-events: none;
    z-index: 8;
}

.qfmc-watermark-logo {
    position: absolute;
    left: 14px;
    bottom: 12px;
    width: 72px;
    height: 72px;
    object-fit: contain;
    opacity: 0.78;
    z-index: 7;
    pointer-events: none;
    filter: drop-shadow(0 4px 10px rgba(15, 23, 42, 0.16));
}

.qfmc-table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.qfmc-table-head h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    color: #111827;
}

.qfmc-table-wrap {
    position: relative;
    width: 100%;
    overflow-x: auto;
    border: 1px solid #eef2f7;
    border-radius: 16px;
    background: #ffffff;
}

.qfmc-price-table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    direction: rtl;
}

.qfmc-price-table th,
.qfmc-price-table td {
    padding: 13px 14px;
    text-align: right;
    border-bottom: 1px solid #eef2f7;
    white-space: nowrap;
    font-size: 14px;
}

.qfmc-price-table th {
    background: #f8fafc;
    color: #374151;
    font-weight: 800;
}

.qfmc-price-table tbody tr:last-child td {
    border-bottom: 0;
}

.qfmc-price-table tbody tr:hover {
    background: #f9fafb;
}

.qfmc-source-name {
    color: #4b5563;
    font-weight: 700;
}

.qfmc-asset-name {
    font-weight: 800;
    color: #111827;
}

.qfmc-change {
    direction: ltr;
    text-align: right;
    font-weight: 800;
}

.qfmc-change--up {
    color: #047857;
}

.qfmc-change--down {
    color: #b91c1c;
}

.qfmc-change--flat {
    color: #4b5563;
}

.qfmc-empty-cell {
    text-align: center !important;
    color: #6b7280;
}

@media (max-width: 1180px) {
    .qfmc-form {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .qfmc-submit {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .qfmc-form {
        grid-template-columns: 1fr;
    }

    .qfmc-widget,
    .qfmc-price-table-widget {
        padding: 12px;
        border-radius: 14px;
    }

    .qfmc-table-head {
        align-items: stretch;
        flex-direction: column;
    }

    .qfmc-table-refresh {
        width: 100%;
    }

    .qfmc-watermark-logo {
        width: 54px;
        height: 54px;
        left: 10px;
        bottom: 10px;
    }
}

.qfmc-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 8px 0 12px;
    padding: 10px;
    border: 1px solid #eef2f7;
    border-radius: 14px;
    background: #f8fafc;
}

.qfmc-tool {
    min-height: 34px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 7px 11px;
    background: #ffffff;
    color: #1f2937;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, transform .2s ease;
}

.qfmc-tool:hover {
    transform: translateY(-1px);
    border-color: #94a3b8;
}

.qfmc-tool.is-active {
    background: #111827;
    border-color: #111827;
    color: #ffffff;
}

.qfmc-tool-danger {
    border-color: #fecaca;
    color: #991b1b;
}

.qfmc-drawing-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 6;
    pointer-events: none;
    cursor: crosshair;
}

.qfmc-drawing-layer.is-enabled {
    pointer-events: auto;
}

.qfmc-risk-lab-badge {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-width: 260px;
    padding: 11px 14px;
    border: 1px solid rgba(17, 24, 39, .12);
    border-radius: 16px;
    background: rgba(17, 24, 39, .92);
    color: #ffffff !important;
    text-decoration: none !important;
    font-family: inherit;
    box-shadow: 0 14px 38px rgba(15, 23, 42, .25);
    backdrop-filter: blur(8px);
}

.qfmc-risk-lab-badge:hover {
    color: #ffffff !important;
    transform: translateY(-1px);
}

.qfmc-risk-lab-badge__title {
    font-size: 13px;
    font-weight: 900;
    line-height: 1.5;
}

.qfmc-risk-lab-badge__text {
    font-size: 11px;
    line-height: 1.7;
    opacity: .9;
}

@media (max-width: 760px) {
    .qfmc-tools {
        gap: 6px;
        padding: 8px;
    }

    .qfmc-tool {
        flex: 1 1 auto;
        min-width: calc(50% - 6px);
    }

    .qfmc-risk-lab-badge {
        left: 10px;
        bottom: 10px;
        max-width: 220px;
        padding: 9px 11px;
    }
}

/* QFMC 1.7.0: stronger technical tools UI, indicator dropdown and fullscreen mode */
.qfmc-tools {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc !important;
    color: #111827 !important;
    z-index: 20;
}

.qfmc-tools-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.qfmc-tools-group--actions {
    margin-right: auto;
}

.qfmc-tools .qfmc-tool,
.qfmc-widget .qfmc-tool,
.qfmc-tools button.qfmc-tool {
    appearance: none;
    -webkit-appearance: none;
    min-height: 36px;
    border: 1px solid #cbd5e1 !important;
    border-radius: 12px !important;
    padding: 8px 12px !important;
    background: #ffffff !important;
    color: #111827 !important;
    font-size: 12px !important;
    font-weight: 900 !important;
    line-height: 1.3 !important;
    text-shadow: none !important;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04) !important;
}

.qfmc-tools .qfmc-tool:hover,
.qfmc-widget .qfmc-tool:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
}

.qfmc-tools .qfmc-tool.is-active,
.qfmc-widget .qfmc-tool.is-active {
    background: #111827 !important;
    border-color: #111827 !important;
    color: #ffffff !important;
}

.qfmc-tools .qfmc-tool-danger,
.qfmc-widget .qfmc-tool-danger {
    background: #fff7f7 !important;
    border-color: #fecaca !important;
    color: #991b1b !important;
}

.qfmc-tools .qfmc-tool-danger:hover,
.qfmc-widget .qfmc-tool-danger:hover {
    background: #fee2e2 !important;
    color: #7f1d1d !important;
}

.qfmc-indicator-menu {
    position: relative;
    display: inline-flex;
    z-index: 30;
}

.qfmc-indicator-menu-button {
    min-width: 132px;
}

.qfmc-indicator-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: none;
    width: 250px;
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid #dbe3ee;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 22px 50px rgba(15, 23, 42, .18);
    z-index: 999;
}

.qfmc-indicator-menu.is-open .qfmc-indicator-dropdown {
    display: grid;
    gap: 5px;
}

.qfmc-indicator-item {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    padding: 8px 10px;
    border-radius: 12px;
    color: #111827 !important;
    background: #ffffff;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

.qfmc-indicator-item:hover,
.qfmc-indicator-item.is-active {
    background: #f1f5f9;
}

.qfmc-indicator-item input {
    width: 16px;
    height: 16px;
    accent-color: #111827;
}

body.qfmc-fullscreen-open {
    overflow: hidden !important;
}

.qfmc-widget.is-fullscreen {
    position: fixed !important;
    inset: 12px !important;
    z-index: 999999 !important;
    display: flex;
    flex-direction: column;
    overflow: auto;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 14px !important;
    border-radius: 18px !important;
    background: #ffffff !important;
    box-shadow: 0 28px 90px rgba(15, 23, 42, .42) !important;
}

.qfmc-widget.is-fullscreen .qfmc-chart {
    flex: 1 1 auto;
    min-height: 360px;
}

.qfmc-widget.is-fullscreen .qfmc-tools {
    position: sticky;
    top: 0;
}

@media (max-width: 760px) {
    .qfmc-tools {
        justify-content: stretch;
    }
    .qfmc-tools-group,
    .qfmc-indicator-menu,
    .qfmc-indicator-menu-button {
        width: 100%;
    }
    .qfmc-tools .qfmc-tool,
    .qfmc-widget .qfmc-tool {
        flex: 1 1 calc(50% - 6px);
        min-width: calc(50% - 6px);
    }
    .qfmc-indicator-dropdown {
        left: 0;
        right: 0;
        width: auto;
    }
    .qfmc-widget.is-fullscreen {
        inset: 6px !important;
        padding: 10px !important;
        border-radius: 14px !important;
    }
}


/* QFMC 1.8.0: indicator panels and font inheritance */
.qfmc-widget,
.qfmc-price-table-widget,
.qfmc-risk-lab-badge {
    font-family: inherit !important;
}

.qfmc-widget input,
.qfmc-widget select,
.qfmc-widget button,
.qfmc-price-table-widget button,
.qfmc-price-table-widget table {
    font-family: inherit !important;
}

.qfmc-indicator-panels {
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.qfmc-indicator-panels:not(.is-visible) {
    display: none;
}

.qfmc-indicator-panel {
    position: relative;
    border: 1px solid #eef2f7;
    border-radius: 16px;
    overflow: hidden;
    background: #ffffff;
}

.qfmc-indicator-panel-title {
    position: absolute;
    top: 9px;
    right: 12px;
    z-index: 4;
    padding: 3px 8px;
    border: 1px solid rgba(226, 232, 240, .9);
    border-radius: 999px;
    background: rgba(248, 250, 252, .92);
    color: #334155;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.5;
    pointer-events: none;
}

.qfmc-indicator-chart {
    width: 100%;
    min-height: 110px;
}

.qfmc-macd-panel .qfmc-indicator-chart {
    min-height: 138px;
}

.qfmc-widget.is-fullscreen .qfmc-indicator-panels {
    flex: 0 0 auto;
}

.qfmc-widget.is-fullscreen .qfmc-indicator-panel {
    min-height: 110px;
}

.qfmc-widget.is-fullscreen .qfmc-macd-panel {
    min-height: 135px;
}
