.havale-kh-box {
    --havale-primary: #2563eb;
    --havale-primary-dark: #1d4ed8;
    --havale-green: #16a34a;
    --havale-green-bg: #ecfdf5;
    --havale-amber: #f59e0b;
    --havale-amber-bg: #fffbeb;
    --havale-chart-base: #2563eb;
    --havale-chart-factory: #94a3b8;
    --havale-chart-opp: #f59e0b;
    --havale-chart-market: #ef4444;
    --havale-text: #1e293b;
    --havale-muted: #64748b;
    --havale-border: #e2e8f0;
    --havale-radius: 14px;

    max-width: 460px;
    margin: 24px 0;
    padding: 24px;
    border: 1px solid var(--havale-border);
    border-radius: var(--havale-radius);
    background: linear-gradient(180deg, #ffffff 0%, #fafbff 100%);
    box-shadow: 0 4px 18px rgba(30, 41, 59, 0.06), 0 1px 3px rgba(30, 41, 59, 0.04);
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    text-align: right;
    box-sizing: border-box;
}

.havale-kh-box * {
    box-sizing: border-box;
}

.havale-kh-box select,
.havale-kh-box button,
.havale-kh-box input {
    font-family: inherit;
}

.havale-kh-box.havale-kh-empty {
    text-align: center;
    color: var(--havale-muted);
    padding: 36px 20px;
    font-size: 14px;
}

/* Header */
.havale-kh-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--havale-border);
}

.havale-kh-header-icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: 12px;
    background: linear-gradient(135deg, #dbeafe, #eef2ff);
}

.havale-kh-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--havale-text);
    line-height: 1.4;
}

.havale-kh-subtitle {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--havale-muted);
}

/* Fields */
.havale-kh-field {
    margin-bottom: 16px;
}

.havale-kh-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.havale-kh-field.is-hidden-field,
.is-hidden-field {
    display: none !important;
}

.havale-kh-field-hint {
    margin: 6px 0 0;
    font-size: 11.5px;
    color: var(--havale-muted);
}

.havale-kh-quote-input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--havale-border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--havale-text);
    background: #f8fafc;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.havale-kh-quote-input:hover {
    border-color: #cbd5e1;
}

.havale-kh-quote-input:focus {
    outline: none;
    border-color: var(--havale-primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Card 2: the buyer/seller's own quoted price, kept visually separate from Card 1 */
.havale-kh-quote-result {
    display: none;
}

.havale-kh-quote-result.is-visible {
    display: block;
    margin-top: 18px;
    padding: 16px;
    background: #f5f3ff;
    border: 1px solid #ddd6fe;
    border-radius: 12px;
    animation: havale-kh-fade-in 0.25s ease;
}

.havale-kh-quote-result .havale-kh-verdict {
    margin: 0;
}

.havale-kh-quote-result .havale-kh-result-note {
    padding-left: 0;
    padding-right: 0;
    margin-top: 8px;
}

.havale-kh-quote-fairness-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #ddd6fe;
    font-size: 12.5px;
    color: #5b21b6;
}

.havale-kh-quote-fairness-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.havale-kh-result-card-title {
    margin: 0;
    padding: 14px 16px 0;
    font-size: 13.5px;
    font-weight: 800;
    color: var(--havale-text);
}

.havale-kh-quote-result .havale-kh-result-card-title {
    padding: 0 0 2px;
    color: #5b21b6;
}

.havale-kh-row-fair-percent {
    background: #eff6ff;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    border-radius: 6px;
    border-bottom-style: solid;
    border-bottom-color: #bfdbfe;
}

.havale-kh-row-fair-percent span {
    color: #1e40af;
}

.havale-kh-row-fair-percent b {
    color: #1d4ed8;
}

.havale-kh-select-wrap {
    position: relative;
}

.havale-kh-select-wrap::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 14px;
    width: 9px;
    height: 9px;
    border-right: 2px solid #94a3b8;
    border-bottom: 2px solid #94a3b8;
    transform: translateY(-65%) rotate(45deg);
    pointer-events: none;
}

.havale-kh-field select {
    width: 100%;
    padding: 11px 40px 11px 14px;
    border: 1.5px solid var(--havale-border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--havale-text);
    background: #f8fafc;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.havale-kh-field select:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.havale-kh-field select:focus {
    outline: none;
    border-color: var(--havale-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Searchable car combobox */
.havale-kh-visually-hidden {
    display: none;
}

.havale-kh-combobox {
    position: relative;
}

.havale-kh-combobox-input {
    width: 100%;
    padding: 11px 40px 11px 14px;
    border: 1.5px solid var(--havale-border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--havale-text);
    background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat left 14px center;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.havale-kh-combobox-input:hover {
    border-color: #cbd5e1;
}

.havale-kh-combobox-input:focus {
    outline: none;
    border-color: var(--havale-primary);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.havale-kh-combobox-panel {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 6px);
    right: 0;
    left: 0;
    max-height: 240px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--havale-border);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    padding: 6px;
}

.havale-kh-combobox.is-open .havale-kh-combobox-panel {
    display: block;
}

.havale-kh-combobox-item {
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13.5px;
    color: var(--havale-text);
    cursor: pointer;
}

.havale-kh-combobox-item:hover,
.havale-kh-combobox-item.is-active {
    background: #eff6ff;
    color: var(--havale-primary-dark);
}

.havale-kh-combobox-group {
    position: sticky;
    top: -6px;
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--havale-muted);
    background: #fff;
}

.havale-kh-combobox-empty {
    padding: 12px;
    font-size: 13px;
    color: var(--havale-muted);
    text-align: center;
}

/* Prices preview chips */
.havale-kh-prices {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 0;
}

.havale-kh-prices.is-visible {
    display: grid;
    margin-bottom: 16px;
    animation: havale-kh-fade-in 0.25s ease;
}

.havale-kh-price-chip {
    background: #f8fafc;
    border: 1px solid var(--havale-border);
    border-radius: 10px;
    padding: 10px 12px;
    text-align: center;
}

.havale-kh-chip-label {
    display: block;
    font-size: 11.5px;
    color: var(--havale-muted);
    margin-bottom: 4px;
}

.havale-kh-price-chip b {
    font-size: 13.5px;
    color: var(--havale-text);
    font-weight: 700;
}

/* Button */
.havale-kh-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--havale-primary), var(--havale-primary-dark));
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.havale-kh-btn:hover {
    filter: brightness(1.06);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.34);
}

.havale-kh-btn:active {
    transform: translateY(1px) scale(0.99);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

/* Result */
.havale-kh-result {
    display: none;
    margin-top: 0;
    border-radius: 12px;
}

.havale-kh-result.is-visible {
    display: block;
    margin-top: 18px;
    animation: havale-kh-fade-in 0.3s ease;
}

.havale-kh-result > * {
    padding-left: 16px;
    padding-right: 16px;
}

.havale-kh-result {
    background: #f8fafc;
    border: 1px solid var(--havale-border);
}

/* Worth-it verdict badge */
.havale-kh-verdict {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 16px 0;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 800;
}

.havale-kh-verdict-icon {
    font-size: 18px;
    line-height: 1;
}

.havale-kh-verdict-good {
    background: var(--havale-green-bg);
    color: #166534;
    border: 1px solid #bbf7d0;
}

.havale-kh-verdict-bad {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.havale-kh-verdict-neutral {
    background: var(--havale-amber-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

.havale-kh-result-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 10px;
    font-size: 13px;
    color: #475569;
    padding-top: 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--havale-border);
}

.havale-kh-result-row:first-child {
    padding-top: 14px;
}

.havale-kh-result-row b {
    color: var(--havale-text);
    font-weight: 700;
    direction: ltr;
    unicode-bidi: plaintext;
    white-space: nowrap;
}

.havale-kh-row-opportunity {
    background: var(--havale-amber-bg);
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    border-radius: 6px;
    border-bottom-style: solid;
    border-bottom-color: #fde68a;
}

.havale-kh-row-opportunity span {
    color: #92400e;
}

.havale-kh-row-opportunity b {
    color: #b45309;
}

.havale-kh-result-final {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 4px 10px;
    padding-top: 14px;
    padding-bottom: 14px;
    background: var(--havale-green-bg);
    border-radius: 0 0 12px 12px;
}

.havale-kh-result-final span {
    font-size: 13.5px;
    font-weight: 700;
    color: #166534;
}

.havale-kh-result-final b {
    font-size: 17px;
    font-weight: 800;
    color: var(--havale-green);
    direction: ltr;
    unicode-bidi: plaintext;
    white-space: nowrap;
}

/* Hint */
.havale-kh-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--havale-muted);
    text-align: center;
    transition: opacity 0.2s ease;
}

.havale-kh-hint.is-hidden {
    opacity: 0;
    height: 0;
    margin-top: 0;
    overflow: hidden;
}

.havale-kh-hint.havale-kh-hint-warn {
    color: #dc2626;
    font-weight: 600;
}

/* Buyer / seller mode toggle */
.havale-kh-mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.havale-kh-mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 1.5px solid var(--havale-border);
    border-radius: 10px;
    background: #f8fafc;
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.havale-kh-mode-btn:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.havale-kh-mode-btn.is-active {
    border-color: var(--havale-primary);
    background: #eff6ff;
    color: var(--havale-primary-dark);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.havale-kh-mode-icon {
    font-size: 15px;
}

/* Pre-sale fixed/non-fixed price toggle */
.havale-kh-presale-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.havale-kh-presale-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 1.5px solid var(--havale-border);
    border-radius: 10px;
    background: #f8fafc;
    color: #64748b;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
}

.havale-kh-presale-btn:hover {
    border-color: #cbd5e1;
    background: #f1f5f9;
}

.havale-kh-presale-btn.is-active[data-fixed="1"] {
    border-color: #16a34a;
    background: var(--havale-green-bg);
    color: #166534;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.havale-kh-presale-btn.is-active[data-fixed="0"] {
    border-color: #dc2626;
    background: #fef2f2;
    color: #b91c1c;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Highlighted breakdown row (matches current buyer/seller mode) */
.havale-kh-result-row.is-highlighted {
    background: #eff6ff;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    border-radius: 6px;
}

.havale-kh-result-row.is-highlighted span {
    color: var(--havale-primary-dark);
    font-weight: 700;
}

.havale-kh-result-row.is-highlighted b {
    color: var(--havale-primary-dark);
}

.havale-kh-result-note {
    margin: 10px 0 14px;
    font-size: 12px;
    color: #64748b;
    text-align: center;
}

/* Comparison chart (three howale types vs market price) */
.havale-kh-chart-box {
    display: none;
    margin-top: 0;
}

.havale-kh-chart-box.is-visible {
    display: block;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--havale-border);
    animation: havale-kh-fade-in 0.3s ease;
}

.havale-kh-chart-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--havale-text);
    text-align: center;
}

.havale-kh-chart {
    width: 100%;
}

.havale-kh-chart-svg {
    width: 100%;
    height: auto;
    display: block;
}

.havale-kh-chart-value {
    font-size: 10px;
    fill: var(--havale-text);
    font-weight: 700;
}

.havale-kh-chart-crown {
    font-size: 13px;
}

.havale-kh-chart-xlabel {
    font-size: 10.5px;
    fill: var(--havale-muted);
    font-weight: 600;
}

.havale-kh-chart-market-line {
    stroke: var(--havale-chart-market);
    stroke-width: 1.5;
    stroke-dasharray: 5 4;
}

.havale-kh-chart-market-label {
    font-size: 10px;
    fill: var(--havale-chart-market);
    font-weight: 700;
}

.havale-kh-chart-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--havale-muted);
}

.havale-kh-chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.havale-kh-legend-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
}

.havale-kh-legend-base {
    background: var(--havale-chart-base);
}

.havale-kh-legend-factory {
    background: var(--havale-chart-factory);
}

.havale-kh-legend-opp {
    background: var(--havale-chart-opp);
}

.havale-kh-legend-market {
    background: var(--havale-chart-market);
}

/* Bargaining ceiling row (buyer mode) */
.havale-kh-row-ceiling {
    background: #fff7ed;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
    border-radius: 6px;
    border-bottom-style: solid;
    border-bottom-color: #fed7aa;
}

.havale-kh-row-ceiling span {
    color: #9a3412;
}

.havale-kh-row-ceiling b {
    color: #c2410c;
}

/* One-line recommendation under the chart */
.havale-kh-recommendation {
    margin: 10px 0 0;
    padding: 10px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 700;
    color: #166534;
    text-align: center;
}

/* Share / copy summary button */
.havale-kh-share-row {
    margin-top: 14px;
    text-align: center;
    position: relative;
}

.havale-kh-share-btn + .havale-kh-share-btn {
    margin-right: 8px;
}

.havale-kh-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 9px 18px;
    border: 1.5px solid var(--havale-border);
    border-radius: 999px;
    background: #fff;
    color: #475569;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.havale-kh-share-btn:hover {
    border-color: var(--havale-primary);
    color: var(--havale-primary-dark);
    background: #eff6ff;
}

.havale-kh-share-toast {
    display: block;
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--havale-muted);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.havale-kh-share-toast.is-visible {
    opacity: 1;
}


/* Shared reveal animation (used instead of max-height tricks, which clip on narrow screens) */
@keyframes havale-kh-fade-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile */
@media (max-width: 480px) {
    .havale-kh-box {
        padding: 16px;
        border-radius: 12px;
        max-width: 100%;
    }

    .havale-kh-verdict {
        font-size: 13px;
        margin: 12px 12px 0;
        padding: 10px 12px;
    }

    .havale-kh-prices {
        grid-template-columns: 1fr;
    }

    .havale-kh-mode-btn {
        font-size: 12px;
        padding: 9px 6px;
    }

    /* Stack label/value instead of squeezing them onto one line */
    .havale-kh-result-row,
    .havale-kh-result-final {
        flex-direction: column;
        align-items: flex-start;
        gap: 3px;
    }

    .havale-kh-result-row b,
    .havale-kh-result-final b {
        white-space: normal;
        word-break: break-word;
    }

    .havale-kh-result-final b {
        font-size: 16px;
    }

    .havale-kh-result-note {
        font-size: 11.5px;
    }

    .havale-kh-chart-value {
        font-size: 9px;
    }

    .havale-kh-chart-xlabel {
        font-size: 9.5px;
    }

    .havale-kh-chart-legend {
        gap: 8px 12px;
        font-size: 10px;
    }
}

