:root {
    /* Light Theme Variables */
    --bg-color: #f0f4f8;
    --sidebar-bg: rgba(255, 255, 255, 0.7);
    --panel-bg: rgba(255, 255, 255, 0.65);
    --panel-border: rgba(255, 255, 255, 0.4);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --accent-color: #4f46e5;
    --accent-hover: #4338ca;
    --accent-light: rgba(79, 70, 229, 0.1);
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: #e2e8f0;
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-blur: blur(12px);
    --profit-color: #059669;
    --loss-color: #dc2626;
}

[data-theme="dark"] {
    /* Dark Theme Variables */
    --bg-color: #0f172a;
    --sidebar-bg: rgba(30, 41, 59, 0.7);
    --panel-bg: rgba(30, 41, 59, 0.65);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #6366f1;
    --accent-hover: #818cf8;
    --accent-light: rgba(99, 102, 241, 0.2);
    --input-bg: rgba(15, 23, 42, 0.8);
    --input-border: #334155;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --profit-color: #10b981;
    --loss-color: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: 
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
}

/* App Layout */
.app-container {
    display: flex;
    width: 95%;
    max-width: 1400px;
    height: 90vh;
    background: var(--sidebar-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: 24px;
    border: 1px solid var(--panel-border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: rgba(0,0,0,0.02);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
}

.logo h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
    color: var(--text-primary);
}

.logo span {
    color: var(--accent-color);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-btn {
    background: transparent;
    border: none;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--accent-light);
    color: var(--accent-color);
}

.nav-btn.active {
    background: var(--accent-color);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.settings {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.premium-select {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
    padding: 0.5rem;
    border-radius: 8px;
    outline: none;
    font-family: inherit;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input-border);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.small-switch {
    width: 32px;
    height: 18px;
}
.small-switch .slider:before {
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
}
.small-switch input:checked + .slider:before {
    transform: translateX(14px);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
    position: relative;
}

.mobile-header {
    display: none;
}

.calc-section {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.calc-section.active {
    display: block;
}

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

.section-header {
    margin-bottom: 2rem;
}

.section-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.section-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Panels */
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

/* Form Elements */
.input-group {
    margin-bottom: 1.2rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 0.8rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.input-wrapper input {
    padding-left: 2.5rem;
}

input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 1rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    width: 100%;
    padding: 0.8rem;
    background: transparent;
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--accent-light);
}

/* Results */
.result-panel {
    display: flex;
    flex-direction: column;
}

.result-panel h3 {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.main-result {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2rem;
    word-break: break-all;
}

.main-result.highlight {
    color: var(--accent-color);
}

.result-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--input-bg);
    border-radius: 12px;
    border: 1px solid var(--input-border);
}

.detail-item {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
}

.profit-text {
    color: var(--profit-color);
    font-weight: 600;
}

.loss-text {
    color: var(--loss-color);
    font-weight: 600;
}

.theory-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--accent-light);
    border-radius: 12px;
    border-left: 4px solid var(--accent-color);
}

.theory-box h4 {
    color: var(--accent-color);
    margin-bottom: 0.5rem;
}

.theory-box p {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-primary);
}

.chart-container {
    flex-grow: 1;
    min-height: 200px;
    position: relative;
    width: 100%;
}

/* Utilities */
.center-content {
    justify-content: center;
    align-items: center;
    text-align: center;
}

.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.flex-row { display: flex; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.text-center { text-align: center; }
.small-text { font-size: 0.8rem; color: var(--text-secondary); }

.divider {
    border: 0;
    height: 1px;
    background: var(--input-border);
    margin: 2rem 0;
    width: 100%;
}

/* Exchange Custom */
.currency-input-group {
    display: flex;
    gap: 0.5rem;
}
.currency-input-group select {
    width: 100px;
}

.swap-icon-container {
    display: flex;
    justify-content: center;
    margin: 0.5rem 0;
}

.icon-btn {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover {
    background: var(--accent-light);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* Responsive Design */
@media (max-width: 968px) {
    .calc-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        border: none;
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 100;
        background: var(--bg-color);
        width: 250px;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
    }

    .mobile-header h2 {
        font-weight: 700;
    }
    .mobile-header span { color: var(--accent-color); }

    #mobile-menu-btn {
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 1.5rem;
        cursor: pointer;
    }

    .main-content {
        padding: 1.5rem;
    }
    
    .glass-panel {
        padding: 1.5rem;
    }
}

/* --- Advanced Options & Table --- */
.advanced-options-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    margin-top: 1rem;
    background: var(--input-bg);
    border: 1px dashed var(--input-border);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.advanced-options-toggle:hover {
    background: var(--accent-light);
    color: var(--accent-color);
    border-color: var(--accent-color);
}
.advanced-options-panel {
    margin-top: 0.5rem;
    padding: 1rem;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    border: 1px solid var(--input-border);
}
[data-theme="dark"] .advanced-options-panel {
    background: rgba(255,255,255,0.03);
}

/* Action Buttons Header */
.panel-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    width: 100%;
}
.panel-header-actions h3 {
    margin-bottom: 0;
}
.action-btns {
    display: flex;
    gap: 0.5rem;
}
.small-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
}

/* Data Table */
.table-container-wrapper {
    width: 100%;
}
.btn-small {
    padding: 0.5rem;
    font-size: 0.8rem;
}
.table-container {
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid var(--input-border);
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) var(--input-bg);
}
.table-container::-webkit-scrollbar {
    width: 6px;
}
.table-container::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 10px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: right;
    color: var(--text-primary);
}
.data-table th, .data-table td {
    padding: 0.6rem;
    border-bottom: 1px solid var(--input-border);
}
.data-table th {
    background: var(--sidebar-bg);
    position: sticky;
    top: 0;
    color: var(--text-secondary);
    font-weight: 600;
}
.data-table th:first-child, .data-table td:first-child {
    text-align: center;
}
.data-table tr:hover td {
    background: var(--accent-light);
}

.full-width {
    width: 100%;
}
.text-left {
    text-align: left;
}

/* --- History Section --- */
.history-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 1rem;
    min-height: 150px;
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0 0.5rem;
}
.history-header h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
}
.clear-history-btn {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    background: transparent;
    border: none;
}
.clear-history-btn:hover {
    background: var(--accent-light);
}
.history-list {
    list-style: none;
    overflow-y: auto;
    padding: 0 0.5rem;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}
.history-list::-webkit-scrollbar {
    width: 4px;
}
.history-list::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}
.history-item {
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.history-item:hover {
    border-color: var(--accent-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transform: translateX(2px);
}
.history-item-type {
    font-size: 0.75rem;
    color: var(--accent-color);
    font-weight: 600;
    margin-bottom: 0.2rem;
}
.history-item-title {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.3;
}
.history-item-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
}
.history-item-delete {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}
.history-item:hover .history-item-delete {
    display: flex;
}
.history-item-delete:hover {
    background: var(--loss-color);
    color: white;
}
.empty-history {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 1rem 0;
    opacity: 0.7;
}

/* --- Dashboard UI --- */
.dashboard-header {
    text-align: center;
    margin-bottom: 2.5rem;
    margin-top: 1rem;
}
.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.dashboard-header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.dashboard-card {
    background: rgba(30, 41, 59, 0.45);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.18);
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
    color: #f8fafc;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 100%);
    pointer-events: none;
}

[data-theme="light"] .dashboard-card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-bottom: 1px solid rgba(0, 0, 0, 0.12);
    color: var(--text-primary);
    box-shadow: 0 8px 24px rgba(31, 38, 135, 0.06);
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px var(--accent-glow), 0 12px 30px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

[data-theme="light"] .dashboard-card:hover {
    box-shadow: 0 12px 30px rgba(0,0,0,0.08), 0 0 0 2px var(--accent-glow);
    border-color: transparent;
}

.card-icon {
    font-size: 3.5rem;
    margin-bottom: 1.2rem;
    color: var(--accent-glow);
    filter: drop-shadow(0 4px 12px var(--accent-glow));
    transition: transform 0.3s ease;
}

.card-icon .material-symbols-rounded {
    font-size: inherit;
    font-weight: 300;
}

.dashboard-card:hover .card-icon {
    transform: scale(1.1);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Premium Accent Colors (Used for icons and glows instead of full backgrounds) */
.card-blue { --accent-glow: rgba(74, 140, 219, 0.5); }
.card-green { --accent-glow: rgba(91, 155, 91, 0.5); }
.card-orange { --accent-glow: rgba(230, 152, 56, 0.5); }
.card-red { --accent-glow: rgba(214, 88, 81, 0.5); }
.card-purple { --accent-glow: rgba(140, 66, 168, 0.5); }
.card-darkblue { --accent-glow: rgba(76, 98, 170, 0.5); }
.card-teal { --accent-glow: rgba(62, 158, 144, 0.5); }

.mr-3 { margin-right: 1rem; }

/* --- Marquee Ticker --- */
.ticker-wrapper {
    width: 100%;
    overflow-x: auto;
    background: var(--input-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 0.8rem 1rem;
    margin-bottom: 2rem;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    cursor: grab;
}

.ticker-wrapper::-webkit-scrollbar {
    display: none;
}

.ticker-track {
    display: inline-flex;
}

.ticker-content {
    display: flex;
    font-size: 0.95rem;
    font-weight: 500;
}

.ticker-item {
    display: inline-block;
    margin-right: 4rem;
}

.ticker-up { color: var(--profit-color); font-weight: 600; margin-left: 0.5rem; }
.ticker-down { color: var(--loss-color); font-weight: 600; margin-left: 0.5rem; }

/* --- Responsive & Mobile Styles --- */
@media screen and (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media screen and (max-width: 768px) {
    .app-container {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        border: none;
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 3000;
        background: var(--sidebar-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 4px 0 15px rgba(0,0,0,0.2);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
        padding: 2rem 1.5rem;
    }
    
    .sidebar .nav-btn {
        text-align: left;
        padding: 1rem 1.2rem;
    }
    
    [data-theme="light"] .sidebar {
        background: rgba(255, 255, 255, 0.95);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.8rem 1.2rem;
        background: var(--sidebar-bg);
        border-bottom: 1px solid var(--panel-border);
    }
    
    .mobile-header h2 {
        font-size: 1.3rem;
        font-weight: 700;
        color: var(--text-primary);
        margin: 0;
    }
    
    .mobile-header h2 span {
        color: var(--accent-color);
    }
    
    #mobile-menu-btn {
        background: transparent;
        border: none;
        font-size: 1.5rem;
        color: var(--text-primary);
        cursor: pointer;
        padding: 0;
    }
    
    .main-content {
        padding: 1rem 0.8rem;
        flex: 1;
        overflow-y: auto;
    }
    
    .dashboard-header {
        margin-bottom: 1rem;
        margin-top: 0;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.2rem;
    }

    .dashboard-header p {
        font-size: 0.85rem;
    }
    
    .ticker-wrapper {
        padding: 0.5rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .ticker-content {
        font-size: 0.85rem;
    }
    
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }
    
    .dashboard-card {
        padding: 1rem 0.5rem;
        border-radius: 12px;
    }
    
    .card-icon {
        font-size: 1.8rem;
        margin-bottom: 0.5rem;
    }
    
    .card-title {
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .calc-grid {
        grid-template-columns: 1fr;
    }
    
    .result-cards {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .input-group.flex-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .input-group.flex-row label {
        margin-bottom: 0.4rem;
    }
    
    .chart-container {
        min-height: 220px;
    }
}
