:root {
    --primary: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #f8fafc;
}

/* Temel yapı düzenlemesi */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    overflow: hidden;
    /* Başlangıçta kilitli */
}

/* Hesaplama yapıldığında veya geçmiş açıldığında kaydırmaya izin ver */
html.is-calculated,
body.is-calculated,
html.history-open,
body.history-open {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    height: auto !important;
    min-height: 100%;
}

/* --- HEADER / LANDING AREA --- */
header.header-panel {
    background: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 2000;
    gap: 40px;
    box-sizing: border-box;
}

body.is-calculated header.header-panel {
    height: 80px;
    flex-direction: row;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
}

.logo-area h2 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary);
    margin: 0;
    transition: 0.4s;
    letter-spacing: -2px;
}

body.is-calculated .logo-area h2 {
    font-size: 1.3rem;
    letter-spacing: -1px;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 90%;
    max-width: 400px;
}

body.is-calculated .input-wrapper {
    flex-direction: row;
    max-width: none;
    width: auto;
    align-items: flex-end;
    gap: 15px;
    flex-wrap: nowrap;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
}

body.is-calculated .input-group:not(.btn-group) {
    flex: 0 0 160px;
    width: 160px;
}

.input-group label {
    font-size: 0.7rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    height: 14px;
    white-space: nowrap;
}

input,
select.limit-select {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.95rem;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    height: 46px;
    background: white;
}

/* --- DASHBOARD LAYOUT --- */
#main-container {
    padding: 20px 30px;
    max-width: 1650px;
    margin: 0 auto;
    display: none;
    opacity: 0;
    transform: translateY(20px);
    transition: 0.5s;
}

body.is-calculated #main-container,
body.history-open #main-container {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: stretch;
}

body:not(.is-calculated) .results-grid {
    display: none;
}

.card {
    background: white;
    border-radius: 28px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    height: 550px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.table-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- HISTORY SECTION --- */
.history-card {
    background: white;
    border-radius: 28px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.03);
    border: 1px solid #e2e8f0;
    margin-top: 30px;
    margin-bottom: 20px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.history-controls {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.history-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(10px);
    margin-bottom: 2px;
}

.history-actions.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.history-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
}

.btn-delete-selected {
    background: #fee2e2;
    color: #ef4444;
}

.btn-delete-selected:hover {
    background: #ef4444;
    color: white;
}

.btn-share-selected {
    background: #eef2ff;
    color: #4f46e5;
}

.btn-share-selected:hover {
    background: #4f46e5;
    color: white;
}

.master-select-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: #f1f5f9;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    margin-bottom: 2px;
    border: 2px solid transparent;
}

.master-select-wrapper:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}

.master-select-wrapper input {
    display: none;
}

.master-select-wrapper svg {
    color: #94a3b8;
    transition: color 0.2s;
}

.master-select-wrapper.checked {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    border-color: var(--primary);
}

.master-select-wrapper.checked svg {
    color: white;
}

.limit-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    position: relative;
}

.limit-label {
    font-size: 0.7rem;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    height: 14px;
}

.select-with-icon {
    position: relative;
    width: 135px;
    overflow: hidden;
    border-radius: 12px;
}

.limit-select {
    height: 40px;
    padding: 0 35px 0 15px;
    font-size: 0.85rem;
    font-weight: 700;
    width: 100%;
    border: 2px solid #f1f5f9;
    color: #475569;
    appearance: none;
    background: white;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    outline: none;
    display: block;
}

.limit-select:hover {
    border-color: #e2e8f0;
}

.limit-select:focus {
    border-color: var(--primary);
}

.select-arrow-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #94a3b8;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 450px;
    overflow-y: auto;
    padding-right: 10px;
    border-top: 1px solid #f1f5f9;
    padding-top: 20px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f8fafc;
    padding: 16px 20px;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    transition: all 0.2s;
    animation: slideIn 0.3s ease-out;
    position: relative;
}

.history-item:hover {
    border-color: var(--primary);
    background: #f1f5f9;
}

.history-content {
    flex: 1;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-text {
    font-size: 0.95rem;
    color: #475569;
    font-weight: 500;
    line-height: 1.5;
}

.history-text b {
    color: #1e293b;
    font-weight: 700;
}

.history-meta {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-badge {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--primary);
    background: #eef2ff;
    padding: 4px 12px;
    border-radius: 20px;
    text-transform: uppercase;
    white-space: nowrap;
}

.history-time {
    font-size: 0.65rem;
    color: #94a3b8;
    font-weight: 600;
}

.btn-item-delete {
    background: none;
    border: none;
    color: #cbd5e1;
    cursor: pointer;
    padding: 5px;
    font-size: 1.1rem;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
}

.btn-item-delete:hover {
    color: var(--danger);
    transform: scale(1.1);
}

.history-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-item:hover .history-checkbox,
.history-item:hover .btn-item-delete,
.history-checkbox:checked {
    opacity: 1;
}

/* --- NOTIFICATION BOX --- */
#msgBox {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 12px 25px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 5000;
    transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#msgBox.show {
    transform: translateX(-50%) translateY(0);
}

/* --- FOOTER OPTIMIZATION --- */
.footer-disclaimer {
    margin-top: 15px;
    padding: 15px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #f1f5f9;
}

.mobile-footer-text {
    display: none;
}

.source-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 600;
}

.yahoo-logo {
    height: 18px;
    width: auto;
    display: block;
}

/* Initial Landing Page Footer */
.landing-footer {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    font-size: 0.8rem;
    transition: opacity 0.3s;
}

body.is-calculated .landing-footer,
body.history-open .landing-footer {
    opacity: 0;
    pointer-events: none;
}

/* Landing Page History Button */
.btn-landing-history {
    background: #f1f5f9;
    color: #64748b;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-landing-history:hover {
    background: #e2e8f0;
    color: var(--primary);
    transform: scale(1.05);
}

body.is-calculated .btn-landing-history {
    display: none;
}

/* Hata Bildir Float Link */
.report-link {
    position: fixed;
    bottom: 20px;
    left: 20px;
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 800;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 5000;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    border-radius: 10px;
    border: 1px solid #fee2e2;
    transition: all 0.2s;
}

.report-link:hover {
    background: #ef4444;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* --- MOBILE REPAIRS --- */
@media (max-width: 768px) {

    header.header-panel:not(body.is-calculated header.header-panel) {
        padding: 20px;
        gap: 30px;
        justify-content: center;
    }

    header.header-panel:not(body.is-calculated header.header-panel) .logo-area h2 {
        font-size: 1.8rem;
    }

    header.header-panel:not(body.is-calculated header.header-panel) .input-wrapper {
        flex-direction: column;
        width: 90%;
        gap: 20px;
    }

    body.is-calculated header.header-panel {
        height: auto;
        min-height: 60px;
        flex-direction: column;
        padding: 8px 10px;
        gap: 5px;
    }

    body.is-calculated .logo-area h2 {
        font-size: 1rem;
    }

    body.is-calculated .input-wrapper {
        flex-direction: row !important;
        width: 100%;
        gap: 4px;
        align-items: flex-end;
    }

    body.is-calculated .input-group:not(.btn-group) {
        flex: 1;
        /* Tutar ve Tarih alanları eşit genişlikte olur */
        width: auto;
        gap: 2px;
    }

    body.is-calculated .btn-group {
        flex: 0 0 auto;
        /* Buton grubu sadece içeriği (Hesapla butonu) kadar yer kaplar */
        width: auto;
    }

    body.is-calculated .input-group label {
        font-size: 0.5rem;
        height: 10px;
    }

    body.is-calculated input {
        height: 32px;
        padding: 4px 8px;
        font-size: 0.75rem;
        border-radius: 8px;
    }

    body.is-calculated .btn-calc {
        height: 32px;
        padding: 0 8px;
        font-size: 0.65rem;
        border-radius: 8px;
        width: auto;
        /* Sadece metnin sığacağı genişlik */
        min-width: fit-content;
    }

    body.is-calculated .btn-landing-history {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .card {
        height: auto;
        min-height: 400px;
        padding: 15px;
    }

    table {
        min-width: 500px;
        table-layout: auto;
    }

    /* GEÇMİŞ BÖLÜMÜ MOBİL İYİLEŞTİRMELERİ */
    .history-item {
        padding: 12px 15px;
        gap: 12px;
        align-items: flex-start;
    }

    .history-checkbox {
        opacity: 1;
        margin-top: 4px;
    }

    .history-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .history-text {
        font-size: 0.85rem;
        line-height: 1.4;
        text-align: left;
    }

    .history-meta {
        text-align: left;
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-top: 1px solid #f1f5f9;
        padding-top: 8px;
    }

    .btn-item-delete {
        opacity: 1;
        padding: 10px;
    }

    /* MOBİL GEÇMİŞ BAŞLIK VE KONTROL SIRALAMASI */
    .history-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }

    .history-controls {
        width: 100% !important;
        justify-content: flex-start !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .limit-container {
        order: 1;
    }

    .master-select-wrapper {
        order: 2;
        margin-bottom: 0 !important;
        width: 34px !important;
        height: 34px !important;
    }

    .history-actions {
        order: 3;
        margin-bottom: 0 !important;
        gap: 8px !important;
    }

    .btn-action-icon {
        width: 34px !important;
        height: 34px !important;
    }

    .btn-action-icon svg,
    .master-select-wrapper svg {
        width: 16px !important;
        height: 16px !important;
    }

    .limit-label {
        display: none !important;
    }

    .select-with-icon {
        width: 85px !important;
    }

    .limit-select {
        height: 34px !important;
        font-size: 0.7rem !important;
        padding: 0 22px 0 8px !important;
        border-radius: 8px;
    }

    .select-arrow-icon {
        right: 6px;
    }

    /* MOBİL FOOTER AYARI */
    .footer-disclaimer {
        padding: 10px;
        font-size: 0.58rem;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .desktop-footer-text {
        display: none;
    }

    .mobile-footer-text {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .yahoo-logo {
        height: 14px;
    }

    .report-link {
        bottom: 10px;
        left: 10px;
        padding: 6px 10px;
        font-size: 0.65rem;
    }
}

.btn-calc {
    padding: 0 30px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    height: 46px;
    white-space: nowrap;
    transition: 0.2s;
    position: relative;
}

.btn-calc.loading {
    color: transparent;
}

.btn-calc.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.export-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f1f5f9;
}

.btn-open-export {
    background: #f1f5f9;
    color: #475569;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-open-export:hover {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.25);
    transform: translateY(-1px);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 30px;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    position: relative;
    text-align: center;
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 20px 0;
}

.export-box {
    border: 2px solid #f1f5f9;
    border-radius: 15px;
    padding: 15px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.export-box:hover {
    border-color: var(--primary);
    background: #f8faff;
}

.period-menu {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 10px;
    flex-direction: row-reverse;
    justify-content: flex-end;
    overflow-x: auto;
    position: relative;
}

.period-btn {
    background: none;
    border: none;
    padding: 5px 8px;
    cursor: pointer;
    font-weight: 700;
    color: #94a3b8;
    font-size: 0.75rem;
    white-space: nowrap;
    position: relative;
}

.period-btn.active {
    color: var(--primary);
}

.period-btn.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
    z-index: 2;
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

th {
    text-align: left;
    color: #94a3b8;
    font-size: 0.8rem;
    text-transform: uppercase;
    padding: 12px 10px;
    border-bottom: 2px solid #f1f5f9;
}

td {
    padding: 18px 10px;
    border-bottom: 1px solid #f8fafc;
    font-size: 0.85rem;
    transition: background 0.2s;
}

tr.asset-row {
    cursor: pointer;
}

tr.asset-row.highlighted {
    background: #f1f5f9 !important;
}

.asset-name {
    font-weight: 800;
    color: #334155;
}

.chart-box {
    height: 400px;
    position: relative;
    overflow: visible !important;
    z-index: 100;
}
