/* === Reset & Base === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --body-bg: #000000;
    --bg-grad-1: #000000;
    --bg-grad-2: #000000;
    --bg-grad-3: #000000;
    --blob-1: #6c63ff;
    --blob-2: #e91e63;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --blur: 16px;
    --radius: 16px;
    --text: #f0f0f0;
    --text-muted: rgba(255, 255, 255, 0.6);
    --accent: #6c63ff;
    --accent-hover: #7b73ff;
    --green: #4caf50;
    --red: #ef5350;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --input-bg: rgba(255, 255, 255, 0.06);
    --hover-bg: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.05);
    --placeholder: rgba(255, 255, 255, 0.3);
    --overlay-bg: rgba(10, 10, 15, 0.6);
    --spinner-border: rgba(255, 255, 255, 0.15);
    --date-scheme: dark;
}

[data-theme="light"] {
    --body-bg: #e8eaf6;
    --bg-grad-1: #e8eaf6;
    --bg-grad-2: #f3e5f5;
    --bg-grad-3: #e1f5fe;
    --blob-1: #b39ddb;
    --blob-2: #f48fb1;
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --text: #1a1a2e;
    --text-muted: rgba(0, 0, 0, 0.5);
    --accent: #5a52d5;
    --accent-hover: #4a42c5;
    --green: #2e7d32;
    --red: #c62828;
    --input-bg: rgba(255, 255, 255, 0.5);
    --hover-bg: rgba(0, 0, 0, 0.04);
    --border-subtle: rgba(0, 0, 0, 0.06);
    --placeholder: rgba(0, 0, 0, 0.3);
    --overlay-bg: rgba(232, 234, 246, 0.7);
    --spinner-border: rgba(0, 0, 0, 0.1);
    --date-scheme: light;
}

[data-theme="light"] .info-icon .info-tip {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a2e;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .sparkline-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a2e;
}

[data-theme="light"] .bubble-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1a1a2e;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

body {
    font-family: var(--font);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--body-bg);
}

/* === Animated Background === */
.bg-animation {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(135deg, var(--bg-grad-1) 0%, var(--bg-grad-2) 50%, var(--bg-grad-3) 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

[data-theme="light"] .bg-animation::before,
[data-theme="light"] .bg-animation::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
}

[data-theme="light"] .bg-animation::before {
    width: 500px;
    height: 500px;
    background: var(--blob-1);
    top: -10%;
    right: -5%;
    animation: float1 20s ease-in-out infinite;
}

[data-theme="light"] .bg-animation::after {
    width: 400px;
    height: 400px;
    background: var(--blob-2);
    bottom: -10%;
    left: -5%;
    animation: float2 25s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-80px, 80px); }
}

@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(60px, -60px); }
}

/* === Glass Effect === */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--glass-shadow);
}

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    margin: 16px;
    border-radius: 12px;
}

.nav-brand {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--green) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* === Widget More Link === */
.widget-more-link {
    display: block;
    text-align: center;
    padding: 8px 0 2px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: opacity 0.2s;
}

.widget-more-link:hover {
    opacity: 0.7;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
}

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

/* === Container === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: var(--text);
}

.btn-primary {
    background: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
}

.btn-outline:hover {
    background: var(--hover-bg);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group input::placeholder {
    color: var(--placeholder);
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
}

.form-group-inline label {
    margin-bottom: 0;
    white-space: nowrap;
}

.form-group-inline input {
    width: auto;
}

/* === Auth Pages === */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 32px;
}

.auth-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-align: center;
}

.auth-subtitle {
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 28px;
    font-size: 0.9rem;
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.auth-link a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(239, 83, 80, 0.15);
    border: 1px solid rgba(239, 83, 80, 0.3);
    color: #ff8a80;
}

.alert-success {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #a5d6a7;
}

/* === Controls === */
.controls {
    padding: 20px 24px;
    margin-bottom: 16px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.date-input {
    color-scheme: var(--date-scheme);
}

.status-text {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* === Loading === */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--spinner-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* === Table === */
.table-wrapper {
    padding: 4px;
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

#trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

#trades-table thead th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color 0.2s;
}

#trades-table thead th:hover {
    color: var(--text);
}

#trades-table thead th.sorted-asc::after {
    content: ' \25B2';
    font-size: 0.7rem;
}

#trades-table thead th.sorted-desc::after {
    content: ' \25BC';
    font-size: 0.7rem;
}

#trades-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s;
}

#trades-table tbody tr:hover {
    background: var(--hover-bg);
}

#trades-table tbody td {
    padding: 10px 14px;
    white-space: nowrap;
}

.ticker-cell {
    font-weight: 600;
    color: var(--accent);
}

.change-positive {
    color: var(--green);
    font-weight: 600;
}

.change-negative {
    color: var(--red);
    font-weight: 600;
}

.change-zero {
    color: var(--text-muted);
}

.num-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* === Summary === */
.summary {
    padding: 12px 14px;
    border-top: 1px solid var(--glass-border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* === Ticker Bar (Marquee) === */
.ticker-bar {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border-bottom: 1px solid var(--glass-border);
    height: 40px;
    overflow: hidden;
    margin: 0 16px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.ticker-track {
    display: flex;
    align-items: center;
    height: 100%;
    white-space: nowrap;
    animation: marquee 40s linear infinite;
    width: max-content;
}

.ticker-track:hover {
    animation-play-state: paused;
}

.ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 16px;
    font-size: 0.85rem;
    border-right: 1px solid var(--border-subtle);
    height: 100%;
}

.ticker-item:last-child {
    border-right: none;
}

.ticker-symbol {
    font-weight: 600;
    color: var(--accent);
}

.ticker-price {
    font-variant-numeric: tabular-nums;
}

.ticker-change {
    font-weight: 600;
    font-size: 0.8rem;
}

.ticker-change.up {
    color: var(--green);
}

.ticker-change.down {
    color: var(--red);
}

.ticker-change.flat {
    color: var(--text-muted);
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* === Dashboard Grid === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

/* === Movers Panel === */
.movers-panel {
    padding: 16px;
    overflow: hidden;
    grid-row: span 2;
}

.panel-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === Info Tooltip === */
.info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1.5px solid var(--text-muted);
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: help;
    position: relative;
    flex-shrink: 0;
    font-style: italic;
    font-family: Georgia, serif;
    line-height: 1;
    transition: border-color 0.2s, color 0.2s;
}

.info-icon:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.info-icon .info-tip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 400;
    font-style: normal;
    font-family: var(--font);
    color: #f0f0f0;
    white-space: normal;
    width: 220px;
    line-height: 1.4;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 100;
    text-align: left;
}

.info-icon:hover .info-tip {
    display: block;
}

/* Arrow */
.info-icon .info-tip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--glass-border);
}

.movers-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 50vh;
}

.movers-empty {
    padding: 12px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.mover-item {
    display: grid;
    grid-template-columns: minmax(80px, 1fr) 100px minmax(70px, auto);
    align-items: center;
    padding: 7px 8px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
    gap: 10px;
}

.mover-item:hover {
    background: var(--hover-bg);
}

.mover-left {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.mover-ticker {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
}

.mover-name {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Sparkline === */
.mover-sparkline {
    width: 100%;
    height: 32px;
    position: relative;
}

.sparkline-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.sparkline-tooltip {
    position: absolute;
    top: -22px;
    transform: translateX(-50%);
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    font-variant-numeric: tabular-nums;
    z-index: 10;
    color: #f0f0f0;
}

.mover-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.mover-price {
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mover-change {
    font-size: 0.78rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ticker-cell {
    font-weight: 600;
    color: var(--accent);
}

/* === News Panel === */
.news-panel {
    padding: 16px;
    overflow: hidden;
    grid-row: span 3;
}

.news-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 70vh;
}

.news-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s;
}

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

.news-item:hover {
    background: var(--hover-bg);
    margin: 0 -8px;
    padding-left: 8px;
    padding-right: 8px;
    border-radius: 8px;
}

.news-title {
    display: block;
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    line-height: 1.4;
    margin-bottom: 4px;
}

.news-title:hover {
    color: var(--accent);
}

.news-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.news-source {
    display: inline-block;
    padding: 1px 8px;
    background: rgba(108, 99, 255, 0.2);
    border: 1px solid rgba(108, 99, 255, 0.3);
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--accent);
}

/* === Dividend Tabs === */
.div-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 8px;
}

.div-tab {
    padding: 8px 16px;
    border: none;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.div-tab:hover {
    color: var(--text);
}

.div-tab.active {
    border-bottom-color: var(--accent);
    color: var(--text);
}

.div-tab-content {
    overflow-y: auto;
    max-height: 50vh;
}

.div-tab-content.hidden {
    display: none;
}

/* === Dividends Panel (Dashboard) === */
.dividends-panel {
    grid-column: 1 / -1;
    padding: 16px;
    overflow: hidden;
}

.dividends-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 50vh;
}

.div-empty {
    padding: 12px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.div-table-header {
    display: flex;
    align-items: center;
    padding: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
}

.div-item {
    display: flex;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid var(--border-subtle);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
    font-size: 0.88rem;
}

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

.div-item:hover {
    background: var(--hover-bg);
    border-radius: 8px;
}

.div-col {
    flex-shrink: 0;
}

.div-ticker {
    width: 25%;
    font-weight: 600;
    color: var(--accent);
}

.div-date {
    width: 30%;
    font-variant-numeric: tabular-nums;
}

.div-value {
    width: 25%;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.div-yield {
    width: 20%;
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.div-yield-high {
    color: var(--green);
    font-weight: 600;
}

/* === Dividend History (Stock Page) === */
.dividend-history {
    padding: 16px;
    overflow: hidden;
}

.div-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.div-history-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
}

.div-history-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.15s;
}

.div-history-table tbody tr:hover {
    background: var(--hover-bg);
}

.div-history-table tbody td {
    padding: 10px 14px;
    white-space: nowrap;
}

/* === Chart Page === */
.chart-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.chart-title-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.back-link:hover {
    color: var(--accent);
}

.chart-ticker {
    font-size: 1.6rem;
    font-weight: 700;
}

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

.ohlc-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    font-variant-numeric: tabular-nums;
}

.ohlc-label {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    margin-left: 8px;
}

.ohlc-label:first-child {
    margin-left: 0;
}

.ohlc-val {
    font-weight: 500;
}

.period-buttons {
    display: flex;
    gap: 6px;
}

.period-btn {
    padding: 6px 16px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.period-btn:hover {
    background: var(--hover-bg);
    color: var(--text);
}

.period-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.chart-container {
    position: relative;
    height: 70vh;
    min-height: 400px;
    padding: 1px;
    overflow: hidden;
}

.chart-container #chart {
    width: 100%;
    height: 100%;
}

.chart-container .loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay-bg);
    z-index: 10;
}

/* === Theme Toggle === */
.theme-toggle {
    font-size: 1.1rem;
    padding: 4px 10px;
    line-height: 1;
    cursor: pointer;
}

/* === Ticker link style === */
.ticker-cell a,
.ticker-symbol a {
    color: inherit;
    text-decoration: none;
}

.ticker-cell a:hover,
.ticker-symbol a:hover {
    text-decoration: underline;
}

/* === Heatmap === */
.heatmap-page {
    display: flex;
    flex-direction: column;
}

.heatmap-container {
    position: relative;
    overflow: hidden;
    padding: 1px;
    min-height: 400px;
}

.heatmap-cell {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    border: 1px solid rgba(0,0,0,0.15);
    transition: opacity 0.15s;
    overflow: hidden;
    cursor: pointer;
}

.heatmap-cell:hover {
    opacity: 0.85;
    z-index: 2;
}

.heatmap-ticker {
    font-weight: 700;
    line-height: 1.2;
}

.heatmap-change {
    font-weight: 500;
    font-size: 0.85em;
    opacity: 0.9;
}

.heatmap-name {
    font-size: 0.7em;
    opacity: 0.7;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Heatmap Widget === */
.heatmap-widget {
    padding: 16px;
    overflow: hidden;
}

/* === Bubbles === */
.bubbles-page {
    display: flex;
    flex-direction: column;
}

.bubbles-container {
    position: relative;
    overflow: hidden;
    min-height: 500px;
    padding: 0;
}

.bubbles-container canvas {
    display: block;
}

.bubble-tooltip {
    position: absolute;
    background: rgba(20, 20, 30, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.82rem;
    color: #f0f0f0;
    pointer-events: none;
    z-index: 20;
    line-height: 1.5;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* === Bubbles Widget === */
.bubbles-widget {
    padding: 16px;
    overflow: hidden;
}

/* === Sentiment === */
.sentiment-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gauge-section {
    padding: 24px;
    text-align: center;
}

.gauge-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.gauge-svg {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.gauge-needle-anim {
    transform-origin: center bottom;
    transition: all 0.8s ease-out;
}

.gauge-score {
    font-size: 2.5rem;
    font-weight: 800;
    margin-top: -8px;
}

.gauge-label {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* === Sentiment Breakdown === */
.breakdown-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.breakdown-card {
    padding: 16px;
}

.breakdown-title {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 6px;
}

.breakdown-value {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.breakdown-bar {
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 6px;
}

.breakdown-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.6s ease-out;
}

.breakdown-detail {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* === Sentiment Widget === */
.sentiment-widget {
    padding: 16px;
    overflow: hidden;
}

.sw-layout {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sw-gauge {
    flex-shrink: 0;
}

.sw-info {
    flex: 1;
    min-width: 0;
}

.sw-score {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.sw-label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
}

.sw-stats {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sw-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
}

.sw-stat-name {
    color: var(--text-muted);
    width: 60px;
    flex-shrink: 0;
}

.sw-stat-bar {
    flex: 1;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    overflow: hidden;
}

.sw-stat-fill {
    height: 100%;
    border-radius: 2px;
}

.sw-stat-val {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    min-width: 32px;
    text-align: right;
}

/* === Sectors === */
.sectors-page {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sectors-top {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 24px;
}

.donut-area {
    flex-shrink: 0;
}

.donut-svg {
    display: block;
    width: 280px;
    height: 280px;
}

.donut-seg {
    transition: opacity 0.2s;
}

.donut-seg:hover {
    opacity: 1 !important;
}

.sector-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    font-size: 0.88rem;
}

.legend-item:hover {
    background: var(--hover-bg);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-name {
    flex: 1;
}

.legend-pct {
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
}

.legend-change {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    min-width: 55px;
    text-align: right;
}

/* === Sectors Widget === */
.sectors-widget {
    padding: 16px;
    overflow: hidden;
}

.widget-sectors-layout {
    display: flex;
    align-items: center;
    gap: 12px;
}

.widget-donut {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
}

.widget-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.wdg-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
}

.wdg-legend-item .legend-dot {
    width: 8px;
    height: 8px;
}

.wdg-legend-item .legend-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wdg-legend-item .legend-change {
    font-size: 0.74rem;
    min-width: 45px;
}

/* === Sector Detail Panel === */
.sector-detail {
    padding: 16px;
}

.sector-detail.hidden {
    display: none;
}

/* === RuTube Video Carousel (Widget) === */
.rutube-widget {
    padding: 16px;
    overflow: hidden;
}

.rutube-carousel {
    display: flex;
    flex-direction: column;
}

.rutube-slide {
    display: block;
    text-decoration: none;
    color: var(--text);
    border-radius: 10px;
    overflow: hidden;
    background: var(--hover-bg);
    transition: transform 0.2s, box-shadow 0.2s;
}

.rutube-slide:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.rutube-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.2);
}

.rutube-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rutube-dur {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    font-variant-numeric: tabular-nums;
}

.rutube-slide-info {
    padding: 8px 10px;
}

.rutube-title {
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 3px;
    min-height: 2.6em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rutube-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.rutube-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 0 0;
}

.rutube-nav-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
}

.rutube-nav-btn:hover:not(:disabled) {
    background: var(--hover-bg);
}

.rutube-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.rutube-counter {
    font-size: 0.74rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* === Responsive: Fold / Small Tablet (481px – 768px) === */
@media (max-width: 768px) and (min-width: 481px) {
    .navbar {
        margin: 6px 8px;
        padding: 8px 14px;
    }

    .nav-brand {
        font-size: 0.95rem;
    }

    .container {
        padding: 8px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-bottom: 8px;
    }

    .movers-panel,
    .news-panel {
        padding: 10px;
    }

    .panel-title {
        font-size: 0.88rem;
        margin-bottom: 6px;
    }

    .movers-list {
        max-height: 52vh;
    }

    .news-list {
        max-height: 65vh;
    }

    .mover-item {
        grid-template-columns: minmax(70px, 1fr) 80px minmax(60px, auto);
        padding: 5px 6px;
        gap: 8px;
    }

    .mover-ticker {
        font-size: 0.8rem;
    }

    .mover-name {
        font-size: 0.68rem;
    }

    .mover-sparkline {
        height: 26px;
    }

    .mover-price {
        font-size: 0.78rem;
    }

    .mover-change {
        font-size: 0.74rem;
    }

    .news-item {
        padding: 8px 0;
    }

    .news-title {
        font-size: 0.84rem;
        line-height: 1.3;
    }

    .news-meta {
        font-size: 0.72rem;
    }

    .ticker-bar {
        margin: 0 8px;
        height: 34px;
        margin-bottom: 4px;
    }

    .ticker-item {
        padding: 0 10px;
        font-size: 0.78rem;
    }

    .controls {
        padding: 12px 14px;
        margin-bottom: 8px;
    }

    .controls-row {
        gap: 10px;
    }

    #trades-table {
        font-size: 0.78rem;
    }

    #trades-table thead th,
    #trades-table tbody td {
        padding: 6px 8px;
    }

    .dividends-panel {
        padding: 10px;
    }

    .div-tab {
        font-size: 0.82rem;
        padding: 6px 12px;
    }

    .div-table-header,
    .div-item {
        font-size: 0.78rem;
        padding: 6px;
    }

    .div-ticker { width: 22%; }
    .div-date { width: 30%; }
    .div-value { width: 28%; }
    .div-yield { width: 20%; }

    .dividend-history {
        padding: 10px;
    }

    .div-history-table {
        font-size: 0.78rem;
    }

    .div-history-table thead th,
    .div-history-table tbody td {
        padding: 6px 8px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-container {
        height: 55vh;
        min-height: 300px;
    }

    .period-buttons {
        flex-wrap: wrap;
    }

    .sectors-top {
        flex-direction: column;
        padding: 14px;
    }

    .donut-svg {
        width: 200px;
        height: 200px;
    }

    .breakdown-grid {
        gap: 8px;
    }

    .breakdown-card {
        padding: 10px;
    }

    .breakdown-value {
        font-size: 1.2rem;
    }

    .nav-link {
        font-size: 0.76rem;
        padding: 4px 8px;
    }

    .rutube-widget {
        padding: 10px;
    }
}

/* === Responsive: Narrow Phone (≤480px) === */
@media (max-width: 480px) {
    .navbar {
        margin: 6px;
        padding: 8px 12px;
    }

    .nav-brand {
        font-size: 0.9rem;
    }

    .container {
        padding: 6px;
    }

    .auth-card {
        padding: 24px 16px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .movers-panel,
    .news-panel {
        grid-row: span 1;
    }

    .movers-list,
    .news-list {
        max-height: 40vh;
    }

    .controls {
        padding: 12px;
        margin-bottom: 8px;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-group-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-group-inline input {
        width: 100%;
    }

    #trades-table {
        font-size: 0.76rem;
    }

    #trades-table thead th,
    #trades-table tbody td {
        padding: 6px 8px;
    }

    .ticker-bar {
        margin: 0 6px;
        height: 32px;
        margin-bottom: 2px;
    }

    .ticker-item {
        padding: 0 8px;
        font-size: 0.74rem;
    }

    .dividends-panel {
        padding: 8px;
    }

    .div-tab {
        font-size: 0.78rem;
        padding: 5px 10px;
    }

    .div-table-header,
    .div-item {
        font-size: 0.74rem;
        padding: 5px;
    }

    .div-ticker { width: 20%; }
    .div-date { width: 30%; }
    .div-value { width: 28%; }
    .div-yield { width: 22%; }

    .dividend-history {
        padding: 8px;
    }

    .div-history-table {
        font-size: 0.76rem;
    }

    .div-history-table thead th,
    .div-history-table tbody td {
        padding: 6px 8px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chart-container {
        height: 55vh;
        min-height: 280px;
    }

    .period-buttons {
        flex-wrap: wrap;
    }

    .period-btn {
        padding: 5px 12px;
        font-size: 0.8rem;
    }

    .sentiment-widget { order: -3; }
    .heatmap-widget { order: -2; }

    .sectors-top {
        flex-direction: column;
        padding: 12px;
    }

    .donut-svg {
        width: 180px;
        height: 180px;
    }

    .widget-sectors-layout {
        flex-direction: column;
        align-items: center;
    }

    .breakdown-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .breakdown-card {
        padding: 12px;
    }

    .breakdown-value {
        font-size: 1.3rem;
    }

    .bubbles-container {
        min-height: 350px;
    }

    .heatmap-container {
        min-height: 300px;
    }

    .nav-link {
        font-size: 0.72rem;
        padding: 3px 6px;
    }

    .page-header h1 {
        font-size: 1.1rem;
    }

    .rutube-widget {
        padding: 8px;
    }
}
