body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background-color: #f3f6fb;
    color: #182235;
    margin: 0;
    padding: 24px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.container {
    max-width: none;
    min-width: 0;
    margin: 0;
}

.market-sidebar {
    display: grid;
    gap: 20px;
}

.market-card {
    padding: 20px;
    background: #ffffff;
    border: 1px solid #dce3ee;
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(24, 34, 53, 0.05);
}

.market-card h2 {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.market-meta, .market-empty {
    color: #64748b;
    font-size: 0.875rem;
}

.container .table-section {
    overflow-x: auto;
}

@media (max-width: 1100px) {
    .dashboard-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

h1, h2 {
    margin-bottom: 15px;
}

.search-wrapper {
    position: relative;
    grid-column: 1 / -1;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-top: 4px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 12px 28px rgba(24, 34, 53, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);

    transition:
        opacity 200ms ease,
        transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1),
        visibility 0s linear 240ms;
}

.search-results.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background-color 150ms ease;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #f3f4f6;
}

.search-name {
    font-weight: bold;
}

.search-meta {
    font-size: 12px;
    color: #666;
}

.summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.summary-card,
.form-section,
.table-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
}

.form-section {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.summary-card p {
    font-size: 24px;
    font-weight: bold;
}

.stock-chart-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-rows: 0fr;
    min-width: 0;
    opacity: 0;
    transition:
        grid-template-rows 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 220ms ease;
}

.stock-chart-panel.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
}

.stock-chart-clip {
    min-height: 0;
    overflow: hidden;
}

.stock-chart-wrapper {
    background: #ffffff;
    border: 1px solid #dce3ee;
    border-radius: 16px;
    padding: 16px;
}

.stock-chart-frame {
    position: relative;
    width: 100%;
    height: 300px;
    transition: opacity 160ms ease;
}

#stock-price-chart {
    display: block;
}

.stock-chart-status {
    min-height: 20px;
    margin: 0 0 12px;
    color: #64748b;
    font-size: 0.875rem;
}

.stock-chart-status.is-error {
    color: #b91c1c;
}

.stock-chart-panel.is-loading .stock-chart-frame {
    opacity: 0.35;
    pointer-events: none;
}

.chart-range-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.range-button {
    width: auto;
    display: inline-block;
    padding: 8px 12px;
    background-color: #e5e7eb;
    color: #374151;
    font-size: 14px;
}

.range-button:hover {
    background-color: #d1d5db;
}

.range-button.active {
    background-color: #111827;
    color: white;
}

.chart-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-top: 30px;
}

.allocation-chart-frame {
    position: relative;
    width: 100%;
    max-width: 320px;
    height: 280px;
    margin: 16px auto 0;
}

#portfolio-chart {
    display: block;
}

form {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

form button {
    grid-column: span 2;
}

input,
button {
    padding: 12px;
    font-size: 16px;
    border-radius: 8px;
}

button {
    background-color: black;
    color: white;
    border: none;
    cursor: pointer;
    width: 100%;
    display: block;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px;
    border-bottom: 1px solid #ddd;
    text-align: left;
}

@media (max-width: 900px) {
    .summary {
        grid-template-columns: 1fr;
    }

    form {
        grid-template-columns: 1fr;
    }

    form button {
        grid-column: span 1;
    }

    table {
        display: block;
        overflow-x: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .search-results,
    .search-result-item {
        transition: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stock-chart-panel,
    .stock-chart-frame {
        transition: none;
    }
}

.market-mover {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
}

.market-mover + .market-mover {
    border-top: 1px solid #edf1f7;
}

.market-mover > div {
    min-width: 0;
}

.market-mover-name {
    display: block;
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #64748b;
    font-size: 0.875rem;
}

.market-mover-values {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.market-change {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 650;
}

.market-change.gain {
    background: #ecfdf5;
    color: #047857;
}

.market-change.loss {
    background: #fef2f2;
    color: #b91c1c;
}

.market-mover-price {
    display: block;
    margin-top: 6px;
    color: #64748b;
    font-size: 0.875rem;
}