/* ── Cash box (uninvested proceeds from sales) ─────────────────── */
.cash-box {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 10px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(133, 187, 101, 0.12), rgba(133, 187, 101, 0.05));
    border: 1px solid rgba(133, 187, 101, 0.4);
    border-radius: 10px;
    font-size: 0.85rem;
    color: #4d7c32;
}
.cash-box-label { font-weight: 600; }
.cash-box-value { font-weight: 700; margin-left: 2px; }
.cash-box-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #85bb65;
    color: #fff;
    font-size: 11px;
    font-style: italic;
    font-weight: 700;
    cursor: help;
    font-family: Georgia, serif;
    line-height: 1;
}

/* ── Sell action icon ──────────────────────────────────────────── */
.action-icon.sell-icon {
    color: #0f1629;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.action-icon.sell-icon svg {
    width: 15px;
    height: 15px;
    display: block;
}
.action-icon.sell-icon:hover {
    color: #16a34a;                        /* green — matches "sell / cash in" */
    background-color: rgba(22, 163, 74, 0.1);
}

/* ── Realized gain badge in Gain/Loss cell ─────────────────────── */
.gl-realized {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 2px;
    opacity: 0.9;
}
.gl-realized.positive { color: #16a34a; }
.gl-realized.negative { color: #dc2626; }

/* ── Sales history table (asset detail) ────────────────────────── */
.asset-sales-section { margin-top: 22px; }
.asset-sales-table thead th { color: #b91c1c; }

/* Sell modal — professional layout */
#sellModal .pro-modal-content {
    max-width: 680px;
    width: min(680px, calc(100vw - 28px));
    border-radius: 16px;
}
#sellModal .pro-modal-header {
    padding-bottom: 18px;
    border-bottom: 1px solid #edf1f5;
}
.sell-modal-body {
    display: grid;
    gap: 16px;
}
#sellModal .form-group { margin-bottom: 0; }
#sellModal .form-group > label {
    display: block;
    margin-bottom: 7px;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #394150;
}
#sellModal .cash-amount-row {
    align-items: flex-start;
    gap: 16px;
}
#sellModal .cash-amount-row .form-group:first-child {
    min-width: 0;
}
#sellModal .cash-amount-row .form-group:last-child {
    flex-basis: 176px !important;
}

/* Sell modal — available banner */
.sell-available-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    margin: 0;
    background: #fff;
    border: 1px solid #edf1f5;
    border-left: 3px solid #e11d48;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.sell-available-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
    border-radius: 8px;
    background: #fff1f2;
    color: #be123c;
}
.sell-available-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.sell-available-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary, #697386);
}
.sell-available-value {
    font-size: 0.95rem;
    color: var(--text-secondary, #697386);
}
.sell-available-value strong {
    font-size: 1.15rem;
    font-weight: 700;
    color: #b91c1c;
}

/* Quantity + MAX shortcut */
.sell-qty-wrap { position: relative; display: flex; align-items: center; }
.sell-qty-wrap input { flex: 1; padding-right: 62px; }
/* "Sell from" mode toggle (FIFO vs Choose lots) */
.sell-mode-toggle {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 5px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: inset 0 1px 1px rgba(16, 24, 40, 0.04);
}
.sell-mode-btn {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 0.79rem;
    font-weight: 600;
    color: #697386;
    background: transparent;
    border: none;
    border-radius: 9px;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.sell-mode-btn:hover { color: #1a1f36; transform: translateY(-1px); }
.sell-mode-btn.active {
    background: #fff;
    color: #b91c1c;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(225, 29, 72, 0.08);
    transform: none;
}

/* Per-lot allocation rows */
.sell-lots-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: clamp(220px, 34vh, 360px);
    overflow-x: hidden;
    overflow-y: scroll;
    overscroll-behavior: contain;
    padding: 10px 10px 10px 10px;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 26%, #ffffff 74%, #f8fafc 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: inset 0 8px 14px rgba(15, 23, 42, 0.035), inset 0 -8px 14px rgba(15, 23, 42, 0.035);
    scrollbar-width: thin;
    scrollbar-color: #be123c #f1f5f9;
}
.sell-lots-list::-webkit-scrollbar {
    width: 10px;
}
.sell-lots-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 999px;
}
.sell-lots-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #fb7185, #be123c);
    border: 2px solid #f1f5f9;
    border-radius: 999px;
}
.sell-lots-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #f43f5e, #9f1239);
}
.sell-lot-row {
    --lot-sold-ratio: 0%;
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 140px;
    align-items: center;
    gap: 12px;
    padding: 10px 11px;
    flex: 0 0 auto;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
    border: 1px solid #edf1f5;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.sell-lot-row::before {
    content: '';
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    width: var(--lot-sold-ratio);
    background: linear-gradient(90deg, #fb7185, #be123c);
    opacity: 0;
    transition: width 0.18s ease, opacity 0.18s ease;
}
.sell-lot-row:hover {
    border-color: #fecdd3;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    transform: translateY(-1px);
}
.sell-lot-row:focus-within,
.sell-lot-row.has-value {
    background: #fffafa;
    border-color: #fb7185;
    box-shadow: 0 8px 20px rgba(190, 18, 60, 0.12);
}
.sell-lot-row.has-value::before { opacity: 1; }
.sell-lot-info { display: grid; gap: 4px; min-width: 0; }
.sell-lot-date { font-size: 0.84rem; font-weight: 700; color: #1a1f36; }
.sell-lot-meta {
    width: fit-content;
    max-width: 100%;
    padding: 3px 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.71rem;
    font-weight: 600;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
}
.sell-lot-qty-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.sell-lot-qty-wrap input {
    width: 100%;
    height: 36px;
    padding-right: 52px;
    font-weight: 700;
    color: #111827;
    background: #ffffff;
    border: 1px solid #dbe3ee;
    border-radius: 9px;
}
.sell-lot-qty-wrap input:focus {
    border-color: #e11d48;
    box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.12);
    outline: none;
}
.sell-lot-max {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    height: 24px;
    min-width: 40px;
    padding: 0 8px;
    font-size: 0.64rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #b91c1c;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.sell-lot-max:hover { background: #be123c; border-color: #be123c; color: #fff; }
.sell-lots-empty { padding: 14px; text-align: center; color: #94a3b8; font-size: 0.85rem; }
.sell-lots-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 12px;
    padding: 10px 12px;
    background: #fff7f8;
    border: 1px solid #fecdd3;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #64748b;
}
.sell-lots-total strong { font-size: 1.12rem; font-weight: 800; color: #b91c1c; }
.sell-max-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    height: 28px;
    min-width: 48px;
    padding: 0 12px;
    line-height: 28px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #b91c1c;
    background: #fff1f2;
    border: 1px solid #fecdd3;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: none;
    overflow: visible;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.sell-max-btn:hover {
    transform: translateY(-50%);
    background: #be123c;
    color: #fff;
    border-color: #be123c;
    box-shadow: none;
}
.sell-max-btn:active {
    transform: translateY(-50%);
    box-shadow: none;
}

@media (max-width: 560px) {
    #sellModal .pro-modal-content {
        width: min(100vw - 18px, 680px);
        max-height: calc(100vh - 18px);
        overflow-y: auto;
    }
    #sellModal .cash-amount-row {
        flex-direction: column;
        gap: 12px;
    }
    #sellModal .cash-amount-row .form-group,
    #sellModal .cash-amount-row .form-group:last-child {
        width: 100%;
        flex-basis: auto !important;
    }
    .sell-mode-toggle { grid-template-columns: 1fr; }
    .sell-lots-list {
        height: min(340px, 40vh);
        padding: 8px;
    }
    .sell-lot-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .sell-lot-qty-wrap { width: 100%; }
}

/* Currency toggle — rose/red theme to match the sell identity */
.sell-cur-toggle {
    background: #f8fafc;
    border: 1px solid #e5eaf0;
    border-radius: 9px;
}
.sell-cur-toggle .cash-cur-btn {
    height: 30px;
    box-shadow: none;
    transform: none;
}
.sell-cur-toggle .cash-cur-btn.active {
    background: #be123c;
    color: #fff;
    box-shadow: 0 1px 3px rgba(190,18,60,0.22);
    transform: none;
}
.sell-cur-toggle .cash-cur-btn:hover:not(.active) {
    background: #fff;
    color: #b91c1c;
    box-shadow: none;
    transform: none;
}
.sell-cur-toggle .cash-cur-btn:active {
    transform: none;
}

/* Confirm button — rose/red gradient */
.sell-confirm-btn {
    background: linear-gradient(135deg, #e11d48, #9f1239) !important;
}
.sell-confirm-btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 6px 16px rgba(159,18,57,0.28);
}

/* Movement type badges (Movement History) */
.mov-badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.4px; }
.mov-badge-buy { background: rgba(34,197,94,0.12); color: #16a34a; }
.mov-badge-sell { background: rgba(239,68,68,0.12); color: #dc2626; }

/* Undo sale button (Sales History + Movement History) */
.sale-undo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: #ffffff;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.sale-undo-btn svg {
    width: 15px;
    height: 15px;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sale-undo-btn:hover {
    color: #dc2626;
    border-color: #fecaca;
    background: #fef2f2;
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.15);
    transform: translateY(-1px);
}
.sale-undo-btn:hover svg {
    transform: rotate(-320deg);
}
.sale-undo-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(220, 38, 38, 0.12);
}


/* Sell modal — manual FX rate card */
.sell-fx-card {
    margin-top: 0;
    padding: 12px;
    background: #fff;
    border: 1px solid #edf1f5;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    transition: border-color 0.2s ease, background 0.2s ease;
}
.sell-fx-card:has(.sell-fx-toggle.active) {
    background: #fafbff;
    border-color: #c7d2fe;
}
.sell-fx-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.sell-fx-heading { display: flex; align-items: center; gap: 8px; }
.sell-fx-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary, #1a1f36);
}
.sell-fx-direction {
    font-size: 0.72rem;
    color: #4f46e5;
    font-weight: 700;
    white-space: nowrap;
}
/* Pill switch */
.sell-fx-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    background: none;
    border: none;
    padding: 0;
    height: auto;
    box-shadow: none;
    transform: none;
    user-select: none;
    transition: color 0.18s ease;
}
.sell-fx-toggle:hover {
    color: #4f46e5;
    background: transparent;
    box-shadow: none;
    transform: none;
}
.sell-fx-toggle:active {
    transform: none;
    box-shadow: none;
}
.sell-fx-toggle.active { color: #6366f1; }
.sell-fx-switch {
    position: relative;
    width: 34px;
    height: 18px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.2s ease;
    flex: 0 0 auto;
}
.sell-fx-switch-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s ease;
}
.sell-fx-toggle.active .sell-fx-switch { background: #4f46e5; }
.sell-fx-toggle.active .sell-fx-switch-thumb { transform: translateX(16px); }
/* Rate input */
#sell-fx-rate {
    margin-top: 10px;
    border: 1.5px solid #c7d2fe;
}
#sell-fx-rate:disabled {
    background: #f1f5f9;
    color: #cbd5e1;
    border-color: #e2e8f0;
    cursor: not-allowed;
}
.sell-fx-note { font-size: 0.7rem; color: #94a3b8; margin: 8px 0 0; }
