/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Base Colors - Premium Dark Theme (Default) */
    --font-family: 'Inter', sans-serif;

    /* Dark Mode Variables (Primary) */
    --bg-body: #0f172a;
    /* Slate 900 - Deep Background */
    --bg-card: #1e293b;
    /* Slate 800 - Card Surface */
    --bg-sidebar: rgba(15, 23, 42, 0.85);
    /* Glassy Sidebar */

    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #cbd5e1;
    /* Slate 300 */
    --text-muted: #94a3b8;
    /* Slate 400 */

    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);

    /* Accents */
    --primary-color: #38bdf8;
    /* Sky 400 */
    --primary-hover: #0ea5e9;
    /* Sky 500 */
    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);

    /* Status Colors */
    --success: #4ade80;
    /* Green 400 */
    --danger: #f87171;
    /* Red 400 */
    --warning: #facc15;
    /* Yellow 400 */

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

/* Light Mode Overrides */
:root:not(.dark-mode) {
    --bg-body: #f8fafc;
    /* Slate 50 */
    --bg-card: #ffffff;
    --bg-sidebar: rgba(255, 255, 255, 0.85);

    --text-primary: #0f172a;
    /* Slate 900 */
    --text-secondary: #475569;
    /* Slate 600 */
    --text-muted: #64748b;
    /* Slate 500 */

    --border-color: #e2e8f0;
    /* Slate 200 */
    --border-hover: #cbd5e1;
    /* Slate 300 */

    --primary-color: #0284c7;
    /* Sky 600 */
    --primary-hover: #0369a1;
    /* Sky 700 */
}

/* Reset & Base */
p {
    line-height: 1.6;
    margin-bottom: 1rem;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-body);
    color: var(--text-secondary);
    font-family: var(--font-family);
    margin: 0;
    font-size: 16px;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text-primary);
    margin-top: 0;
    font-weight: 600;
    letter-spacing: -0.025em;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
}

/* Auth Page */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at top right, #1e293b 0%, #0f172a 100%);
}

.auth-container {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border-color);
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.75rem;
}

/* Layout */
body {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    padding: 24px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar h2 {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    padding-left: 12px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 700;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar li {
    margin-bottom: 8px;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.sidebar a:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.sidebar a.active {
    background-color: rgba(56, 189, 248, 0.1);
    color: var(--primary-color);
    box-shadow: inset 3px 0 0 var(--primary-color);
    /* Left accent bar */
}

.sidebar a i {
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    max-height: 100vh;
}

.main-content>* {
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

/* New Global App Header */
#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 0;
}

#app-header .global-search-container {
    width: 25%;
    min-width: 250px;
    position: relative;
}

#app-header .user-info {
    font-weight: 500;
    color: var(--text-muted);
}

/* Page Title Bar Layout (replaces old header functionality) */
.page-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title-bar h1 {
    font-size: 2rem;
    margin: 0;
}

.page-title-bar .actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.card {
    background-color: var(--bg-card);
    padding: 24px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-hover);
}

.card h3,
.card h2 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.amount {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 4px 0 0;
    letter-spacing: -0.02em;
}

.chart-container {
    min-height: 450px;
    position: relative;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.chart-header h3 {
    margin: 0;
}

.chart-controls {
    display: flex;
    gap: 6px;
}

.range-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.range-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.range-btn.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.chart-container canvas {
    flex: 1;
    min-height: 0;
}

/* Two-column charts row */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 40px;
}

/* Donut card overrides */
.donut-card {
    height: 450px;
    display: flex;
    flex-direction: column;
}

.donut-wrapper {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 0;
}

.donut-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
    cursor: pointer;
}

/* Active ticker filter chip in trend chart header */
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 20px;
    padding: 3px 10px 3px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    animation: fadeIn 0.2s ease;
}

.filter-chip-label {
    letter-spacing: 0.03em;
}

.filter-chip-reset {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.filter-chip-reset:hover {
    opacity: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive: stack charts vertically on smaller screens */
@media (max-width: 1100px) {
    .charts-row {
        grid-template-columns: 1fr;
    }

    .donut-card {
        height: 350px;
    }
}


/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

/* Custom trend chart tooltip */
.trend-tooltip {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s ease;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    min-width: 220px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-size: 0.82rem;
}

.tt-date {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.tt-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.tt-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tt-label {
    flex: 1;
    color: var(--text-secondary);
}

.tt-value {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.tt-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 8px 0;
}

.tt-gain .tt-label,
.tt-gain .tt-value {
    color: #4ade80;
}

.tt-loss .tt-label,
.tt-loss .tt-value {
    color: #f87171;
}


.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-card);
    /* Changed to solid for better contrast */
    color: var(--text-primary);
    font-family: var(--font-family);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    appearance: none;
}

select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

/* Specific Select Styles */
select {
    padding-right: 2.5rem;
    /* Make room for arrow */
    cursor: pointer;
}

/* Option Styles for Dark Mode Visibility */
option {
    background-color: var(--bg-card);
    color: var(--text-primary);
    padding: 10px;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all var(--transition-fast);
    gap: 8px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(56, 189, 248, 0.4);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-sm:hover {
    background-color: var(--bg-body);
    border-color: var(--text-muted);
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 16px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
    color: var(--text-primary);
}

/* Status Colors used in Table */
.gain-positive {
    color: var(--success);
    font-weight: 600;
}

.gain-negative {
    color: var(--danger);
    font-weight: 600;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.8);
    /* Dark blur overlay */
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-card);
    margin: 5% auto;
    padding: 32px;
    border-radius: 20px;
    width: 600px;
    /* Increased default width */
    max-width: 95%;
    /* Allowed more width on small screens */
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    animation: slideIn 0.3s ease-out;
    max-height: 90vh;
    /* Prevent modal from exceeding viewport height */
    overflow-y: auto;
    /* Allow modal itself to scroll if needed */
}

/* Specific wider modal for CSV Import */
#csvModal .modal-content {
    width: 900px;
}

.preview-container {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close,
.csv-close,
.history-close {
    position: absolute;
    right: 24px;
    top: 24px;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: var(--text-primary);
}

/* Utility / Misc */
.text-muted {
    color: var(--text-muted) !important;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
}

.checkbox input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox label {
    margin: 0;
    cursor: pointer;
}

/* CSV Import Wizard */
.mapping-row {
    display: grid;
    grid-template-columns: 1fr 2fr;
    align-items: center;
    padding: 8px 0;
    gap: 16px;
}

#previewTable {
    font-size: 0.9rem;
}

#previewTable input {
    font-size: 0.9rem;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* Drop Zone Styles */
.drop-zone {
    width: 100%;
    height: 200px;
    padding: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-weight: 500;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-muted);
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
    background-color: rgba(255, 255, 255, 0.02);
    position: relative;
}

.drop-zone--over {
    border-style: solid;
    border-color: var(--primary-color);
    background-color: rgba(56, 189, 248, 0.05);
    /* Tint of primary color */
    color: var(--primary-color);
}

.drop-zone__input {
    display: none;
}

.drop-zone__thumb {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
    background-color: #cccccc;
    background-size: cover;
    position: relative;
}

.drop-zone__thumb::after {
    content: attr(data-label);
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 5px 0;
    color: #ffffff;
    background: rgba(0, 0, 0, 0.75);
    font-size: 14px;
    text-align: center;
}

.drop-zone__remove {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(248, 113, 113, 0.2);
    /* Red tint */
    color: var(--danger);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 10;
}

.drop-zone__remove:hover {
    background: var(--danger);
    color: white;
}

/* Toggle Switch */
.toggle-switch {
    display: inline-block;
    position: relative;
    width: 36px;
    /* Further reduced from 44px */
    height: 20px;
    /* Further reduced from 24px */
    flex: 0 0 36px;
    /* Fix width */
    margin-left: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 20px;
    /* Adjusted radius */
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    /* Reduced from 18px */
    width: 16px;
    /* Reduced from 18px */
    left: 2px;
    /* Adjusted spacing */
    bottom: 2px;
    /* Adjusted spacing */
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(16px);
    /* Adjusted translation (36 - 2 - 2 - 16 = 16) */
}

/* Update Settings Page Checkbox Layout for Toggles */
.form-group.toggle-row {
    display: flex;
    justify-content: flex-start;
    /* Changed from space-between to flex-start */
    align-items: center;
    background-color: rgba(255, 255, 255, 0.02);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    gap: 20px;
    /* Add gap between text and toggle */
}

/* Expandable Rows */
.toggle-row-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: transform 0.3s ease;
}

.toggle-row-btn:hover {
    color: var(--primary-color);
}

.toggle-row-btn.expanded {
    transform: rotate(90deg);
    color: var(--primary-color);
}

.expanded-row {
    background-color: rgba(255, 255, 255, 0.01);
}

.transaction-details-row td {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
}

.transaction-details-container {
    padding: 15px;
    /* Reverted as requested */
    background-color: rgba(15, 23, 42, 0.3);
    /* Darker background */
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

.transaction-table {
    width: 100%;
    font-size: 0.9em;
}

.transaction-table th {
    color: var(--text-muted);
    font-weight: 500;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

.transaction-table td {
    padding: 10px;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Align Date Column to right, but remove left padding to shift it left */
.transaction-table th:first-child,
.transaction-table td:first-child {
    text-align: right;
    padding-left: 0;
    /* Shift content left */
}

.transaction-table tr:last-child td {
    border-bottom: none;
}

.form-group.toggle-row>label:not(.toggle-switch),
.form-group.toggle-row>div {
    margin: 0;
    font-size: 1rem;
    cursor: default;
    flex: 0 1 auto;
    /* Don't force full width */
}

/* --- Search & Market Page --- */
.search-container {
    padding: 20px;
    margin-bottom: 20px;
    position: relative;
    overflow: visible;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input-wrapper input,
.search-input-wrapper input[type="text"] {
    width: 100%;
    padding: 12px 15px 12px 40px !important;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 20px;
    right: 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.search-result-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.search-result-item .symbol {
    font-weight: bold;
    color: var(--primary-color);
    width: 80px;
}

.search-result-item .name {
    flex-grow: 1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 10px;
}

.search-result-item .exchange {
    color: var(--text-muted);
    font-size: 0.8em;
}

/* Stock Details */
.stock-details-container {
    animation: fadeIn 0.3s ease;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 24px;
    margin-bottom: 2rem;
}

.details-left h2 {
    font-size: 2rem;
    margin: 0;
    color: var(--text-primary);
}

.details-left h3 {
    margin: 5px 0 10px;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: normal;
}

.details-left h5,
h6 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
}

.stock-link {
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.stock-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.details-right {
    text-align: right;
}

.price-large {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

.change-large {
    font-size: 1.2rem;
}

.details-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .details-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    height: 500px;
    display: flex;
    flex-direction: column;
}

.chart-container {
    flex-grow: 1;
    position: relative;
    min-height: 0;
}

.chart-controls {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.chart-controls .btn-sm {
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
}

.chart-controls .btn-sm.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.stats-card {
    padding: 24px;
}

.stats-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
}

.stats-list li {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.stats-list li:last-child {
    border-bottom: none;
}

.stats-list span:first-child {
    color: var(--text-muted);
}

.stats-list span:last-child {
    font-weight: 500;
}

.description-text {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

/* Global Search in Header */
.global-search-container {
    position: relative;
    margin: 0 40px;
    flex-grow: 1;
    /* Takes up available space */
    max-width: 600px;
    /* Increased width */
}

#globalSearchInput {
    width: 100%;
    padding: 12px 20px;
    /* Larger padding */
    font-size: 1.1rem;
    /* Larger font */
    border-radius: 24px;
    /* More rounded */
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s;
    height: 50px;
    /* Fixed height for consistency */
}

#globalSearchInput:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 208, 132, 0.2);
}

#globalSearchResults {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    display: none;
}

.global-search-item {
    padding: 10px 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.global-search-item:last-child {
    border-bottom: none;
}

.global-search-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.global-search-item .symbol {
    font-weight: bold;
    color: var(--primary-color);
}

.global-search-item .name {
    font-size: 0.9em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

/* Suggestions Dropdown */
.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-lg);
}

.suggestions-list.active {
    display: block;
}

.suggestion-item {
    padding: 10px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: var(--border-hover);
}

.suggestion-item .ticker {
    font-weight: 600;
    color: var(--text-primary);
}

/* Chart Controls */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.chart-controls {
    display: flex;
    gap: 5px;
    background: var(--bg-default);
    padding: 3px;
    border-radius: 8px;
}

.range-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 600;
    transition: all 0.2s;
}

.range-btn:hover {
    color: var(--text-primary);
    background-color: var(--border-color);
}

.range-btn.active {
    background-color: var(--primary-color);
    color: #fff;
}

.suggestion-item .name {
    font-size: 0.9em;
    color: var(--text-muted);
}

/* Custom Trend Chart Legend */
.custom-legend-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    padding-top: 12px;
    margin-top: auto;
    /* Push to bottom of chart container */
}

.custom-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: opacity var(--transition-fast);
    user-select: none;
}

.custom-legend-item:hover {
    opacity: 0.8;
}

.custom-legend-item.hidden {
    text-decoration: line-through;
    opacity: 0.5;
}

.custom-legend-color-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

/* Dropdown Menu Styles */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-card);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    top: 100%;
    right: 0;
    margin-top: 5px;
}

.dropdown-content div,
.dropdown-content label {
    display: block;
    padding: 6px 0;
    cursor: pointer;
    color: var(--text-primary);
    white-space: nowrap;
}

.dropdown-content div:hover,
.dropdown-content label:hover {
    color: var(--primary-color);
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content.show {
    display: block;
}

/* --- Mobile Responsive Overrides --- */
@media (max-width: 768px) {
    body {
        /* Prevents body from scrolling when sidebar is open */
        overflow-x: hidden;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    /* Sidebar Off-Canvas */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        width: 280px;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    /* Sidebar Overlay Backdrop */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-normal);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main Content Adjustments */
    .main-content {
        padding: 15px;
    }

    /* Header Adjustments */
    #app-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
        margin-bottom: 20px;
    }

    .header-top-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .mobile-menu-btn {
        display: flex;
        background: none;
        border: none;
        color: var(--text-primary);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 5px;
    }

    #app-header .global-search-container {
        width: 100%;
        min-width: unset;
    }

    /* Page Title Bar Adjustments */
    .page-title-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .page-title-bar .actions,
    .page-title-bar .actions>.dropdown,
    .page-title-bar .actions>.form-group {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
    }

    .page-title-bar .btn,
    .page-title-bar select {
        flex: 1;
        text-align: center;
        justify-content: center;
    }

    /* Tables Overflow */
    .card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
        /* Ensure tables don't compress infinitely */
    }

    /* Modal Adjustments */
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
}

/* Hide mobile menu button on desktop */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important;
    }
}