:root {
    /* Color Palette - Premium Dark Theme */
    --bg-dark: #0f1218;
    --bg-panel: rgba(26, 31, 44, 0.7);
    --bg-panel-hover: rgba(36, 43, 61, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);

    --primary: #00f0ff;
    --primary-glow: rgba(0, 240, 255, 0.3);

    --success: #00e676;
    --success-bg: rgba(0, 230, 118, 0.1);

    --danger: #ff3366;
    --danger-bg: rgba(255, 51, 102, 0.1);

    --text-main: #f0f2f5;
    --text-muted: #94a3b8;

    /* Variables */
    --font-family: 'Inter', sans-serif;
    --border-radius: 16px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Shadows */
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 15px var(--primary-glow);
}

/* Base Styles & Resets */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 240, 255, 0.25);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 240, 255, 0.5);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 240, 255, 0.25) transparent;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    /* Add subtle background pattern/gradient */
    background-image: radial-gradient(circle at 15% 50%, rgba(0, 240, 255, 0.05), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(255, 51, 102, 0.05), transparent 25%);
}

.app-container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

/* Typography and Utilities */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
}

.primary-text {
    color: var(--primary);
}

.success-text {
    color: var(--success);
}

.danger-text {
    color: var(--danger);
}

.sub-text {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-right: 1px solid var(--border-color);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
    font-size: 1.05rem;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--bg-panel-hover);
    color: var(--primary);
    border-left: 4px solid var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary);
}

.user-name {
    font-weight: 500;
    font-size: 0.95rem;
}

/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 32px 48px;
    position: relative;
}

/* Custom Scrollbar for Main Content */
.main-content::-webkit-scrollbar {
    width: 8px;
}

.main-content::-webkit-scrollbar-track {
    background: transparent;
}

.main-content::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 20px;
}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.header-title h1 {
    font-size: 2rem;
    margin-bottom: 4px;
}

.date-display {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: 16px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    font-family: var(--font-family);
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-icon:hover {
    background: var(--bg-panel-hover);
    color: var(--primary);
}

.btn-primary {
    background: var(--primary);
    color: var(--bg-dark);
    font-weight: 600;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-block {
    width: 100%;
    padding: 14px;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-close:hover {
    color: var(--danger);
    transform: scale(1.1);
}

/* Sections */
.sections-container {
    position: relative;
    flex: 1;
}

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

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

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

/* Cards */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 24px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-glass);
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.card-header h3 {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 1rem;
}

.card-icon {
    font-size: 1.5rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.total-balance {
    grid-column: span 1;
}

.balance-amount {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.trend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.trend.positive {
    color: var(--success);
}

.trend.negative {
    color: var(--danger);
}

/* Charts Area */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.chart-card {
    min-height: 350px;
}

.chart-container {
    height: 300px;
    width: 100%;
    margin-top: 16px;
}

/* Tables */
.table-card {
    padding: 0;
    overflow: hidden;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th,
.data-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(0, 0, 0, 0.1);
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

.badge.income {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(0, 230, 118, 0.2);
}

.badge.expense {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(255, 51, 102, 0.2);
}

.badge.long {
    background: rgba(0, 240, 255, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary-glow);
}

.badge.short {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

/* Buttons inside table */
.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 6px;
    border-radius: 4px;
    transition: var(--transition);
}

.action-btn.delete:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

/* Empty State */
.empty-state {
    padding: 48px;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.empty-state i {
    font-size: 3rem;
    opacity: 0.5;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 100%;
    max-width: 500px;
    border-radius: var(--border-radius);
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-body {
    padding: 24px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}

::placeholder {
    color: rgba(148, 163, 184, 0.4);
}

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

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 16px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .logo {
        margin-bottom: 0;
    }

    .logo h2,
    .user-profile,
    .nav-item span {
        display: none;
    }

    .nav-menu {
        flex-direction: row;
        gap: 16px;
    }

    .nav-item {
        padding: 10px;
    }

    .sidebar-footer {
        padding-top: 0;
        border-top: none;
        margin-top: 0;
    }

    .main-content {
        padding: 24px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* Login Screen */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    background: var(--bg-dark);
    /* Extra subtle pattern */
    background-image: radial-gradient(circle at 50% 50%, rgba(0, 240, 255, 0.1), transparent 40%);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.login-overlay.active {
    opacity: 1;
    visibility: visible;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-glass);
    text-align: center;
}

.login-container .logo {
    justify-content: center;
    margin-bottom: 16px;
}

.login-subtext {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 32px;
}

/* -------------------------------------------------------------
 * P&L Calendar
 * ------------------------------------------------------------- */
.pnl-calendar-card {
    background: #1e222d;
    border: 1px solid #2a2e39;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
}

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #2a2e39;
    padding: 6px 12px;
    border-radius: 6px;
}

.cal-month-display {
    font-weight: 500;
    min-width: 90px;
    text-align: center;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(5, 167.87px);
    gap: 1px;
    background: #2a2e39;
    border: 1px solid #2a2e39;
    border-radius: 6px;
    overflow: hidden;
}

.cal-header-cell {
    background: #1e222d;
    padding: 12px 10px;
    text-align: center;
    font-weight: 500;
    color: #94a3b8;
    font-size: 0.95rem;
}

.cal-cell {
    background: #1e222d;
    padding: 14px 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0px;
    height: 100px;
    justify-content: flex-start;
}

.cal-cell.empty {
    background: #161922;
}

.cal-cell.profit {
    background: rgba(0, 230, 118, 0.12);
}

.cal-cell.loss {
    background: rgba(255, 51, 102, 0.12);
}

.cal-date {
    font-size: 1.05rem;
    font-weight: 500;
}

.cal-cell.empty .cal-date {
    color: #475569;
}

.cal-pnl {
    font-size: 0.95rem;
    font-weight: 600;
}

/* -------------------------------------------------------------
 * Toggle Buttons (Income/Expense, Long/Short)
 * ------------------------------------------------------------- */
.toggle-group {
    display: flex;
    gap: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.toggle-btn {
    flex: 1;
    padding: 10px 16px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s ease;
}

.toggle-btn:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.04);
}

/* Income active */
.toggle-btn.income-toggle.active {
    background: rgba(0, 230, 118, 0.15);
    color: var(--success);
    font-weight: 600;
}

/* Expense active */
.toggle-btn.expense-toggle.active {
    background: rgba(255, 51, 102, 0.15);
    color: var(--danger);
    font-weight: 600;
}

/* Long active */
.toggle-btn.long-toggle.active {
    background: rgba(0, 230, 118, 0.15);
    color: var(--success);
    font-weight: 600;
}

/* Short active */
.toggle-btn.short-toggle.active {
    background: rgba(255, 51, 102, 0.15);
    color: var(--danger);
    font-weight: 600;
}

/* Hide number input spin buttons */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* White calendar icon for date inputs */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}