@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@700&family=Cabin:wght@600&family=Fira+Sans:wght@400&family=Lato:wght@300&display=swap');

.position-bubble { margin-left: 8px; padding: 2px 6px; border-radius: 12px; font-size: 12px; }
.position-bubble.pos-gain { background: rgba(111,191,115,0.18); color: var(--color-bull); }
.position-bubble.pos-loss { background: rgba(214,106,106,0.18); color: var(--color-bear); }
.position-bubble.pos-flat { background: var(--color-neutral); color: #333; }
.kv-actions { margin-left: 8px; }
.kv-actions button { margin-left: 6px; }

/* Transaction box */
.txn-box { border: 1px solid #ddd; border-radius: 8px; padding: 8px; background: #fff; }
.txn-header { font-weight: 600; margin-bottom: 6px; }
.txn-list { display: grid; gap: 6px; }
.txn-row { display: grid; grid-template-columns: repeat(5, auto); gap: 8px; align-items: center; }
.txn-field .label { display: block; font-size: 11px; color: #666; }
.txn-field .value { display: block; font-size: 13px; }
.txn-actions button { margin-left: 6px; }
.txn-list.empty { color: #666; font-style: italic; }
.txn-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.txn-col-title { font-weight: 600; margin-bottom: 4px; }
.txn-item { border: 1px solid #eee; padding: 6px; border-radius: 6px; background: #fafafa; }
.txn-item .label { display: block; font-size: 11px; color: #666; }
.txn-item .value { display: block; font-size: 13px; }
.txn-empty { color: #666; font-style: italic; }
body {
    font-family: var(--font-base);
    font-size: 16px;
    margin: 0;
    padding: 0;
    line-height: 1.5;
}
/* Theme variables */
:root {
    --color-primary: #1E3A7D;
    --color-secondary: #5D80B4;
    --color-accent: #E08369;    /* Highlight */
    --color-neutral: #C6CCDC;
    --color-bull: #73A97F;
    --color-bear: #d66a6a;
    --color-header: #ABBF9F;

    /* Typography */
    --font-brand: 'Symphony', 'Cormorant Garamond', serif;
    --font-nav: 'Cormorant Garamond', serif;
    --font-title: 'Avenir Next', Avenir, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-subtitle: 'Cabin', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-field: 'Fira Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-value: 'Lato', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-base: 'Fira Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
header {
    background: var(--color-header, #ABBF9F);
    background-color: var(--color-header, #ABBF9F) !important;
    color: #fff;
    padding: 12px 16px;
    font-size: 18px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-auto-rows: auto;
    align-items: center;
    gap: 8px 12px;
    position: relative;
    opacity: 1 !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}
header > nav { grid-column: 2; justify-self: center; }
.home-header {
    grid-template-rows: auto auto;
    align-items: start;
}
.home-header .last-update-badge {
    grid-column: 3;
    align-self: end;
    justify-self: end;
    margin-top: 4px;
}
/* Site logo */
.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.site-logo img {
    display: block;
    height: 42px;
    width: auto;
}
.site-logo .brand-text {
    color: #e6e6e6;
    font-weight: 600;
    text-decoration: none;
    font-family: var(--font-brand);
}

/* Ensure the logo link is never underlined */
.site-logo,
.site-logo:link,
.site-logo:visited,
.site-logo:hover,
.site-logo:focus,
.site-logo:active {
    text-decoration: none;
}

/* Home hero logo */
.home-hero {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2px 0 0 0;
    grid-column: 1 / -1;
}
.home-hero img {
    max-width: 280px;
    width: 60%;
    height: auto;
}
/* Tighter spacing on home page */
main.home { padding-top: 6px; }
.home-hero + h1 { margin-top: 6px; }
/* Home welcome box spacing */
.welcome-box { margin: 12px 16px; }
/* Last update badge */
.last-update-badge {
    margin-left: 8px;
    background: var(--color-secondary);
    color: #fff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    justify-self: end;
    position: static; /* do not float over links */
    top: auto;
    right: auto;
}
.home-header .last-update-badge {
    position: static; /* override absolute for home page */
    top: auto;
    right: auto;
    grid-column: 1 / -1;
    justify-self: center;
    align-self: start;
    font-size: 14px;
    padding: 6px 12px;
    line-height: 1.3;
    white-space: normal;
}
.header-badges { grid-column: 3; justify-self: end; display: grid; grid-auto-flow: row; justify-items: end; gap: 8px; align-items: end; }
.header-badges .auth-badge-btn { padding: 6px 12px; border-radius: 999px; border: 1px solid #ddd; background: #fff; font-size: 14px; cursor: pointer; justify-self: end; }
.home-header .header-badges .auth-badge-btn { justify-self: end; }
nav a {
    color: #fff;
    margin-right: 16px;
    text-decoration: none;
    font-size: 16px;
    font-family: var(--font-nav);
    font-weight: 700;
}
/* Dropdown menu in header */
.dropdown { position: relative; display: inline-block; }
.dropdown-toggle { color: #fff; text-decoration: none; margin-right: 16px; display: inline-block; font-family: var(--font-nav); font-weight: 700; }
.dropdown-toggle.locked { opacity: 0.85; }
.lock-icon { margin-left: 2px; }
.dropdown-menu { display: none; position: absolute; top: 100%; left: 0; background: #fff; color: var(--color-primary); min-width: 220px; border: 1px solid #ddd; border-top: none; border-radius: 0 0 6px 6px; box-shadow: 0 4px 10px rgba(0,0,0,0.12); z-index: 1000; }
.dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a { display: block; padding: 10px 12px; color: var(--color-primary); text-decoration: none; border-bottom: 1px solid #eee; }
.dropdown-menu a.locked { color: #888; }
.lock-tooltip {
    position: absolute;
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 2000;
    pointer-events: none;
    white-space: nowrap;
}
.dropdown-menu a:last-child { border-bottom: none; }
.dropdown-menu a:hover { background: #f5f5f5; }
button {
    cursor: pointer;
    font-size: 16px;
    font-family: inherit;
}
h1, h2, h3 {
    font-family: var(--font-title);
    line-height: 1.3;
}
h1 { font-size: 28px; font-weight: 500; }
h2 { font-size: 24px; font-family: var(--font-subtitle); font-weight: 600; }
h3 { font-size: 20px; font-family: var(--font-subtitle); font-weight: 600; }
/* Table styles for responsiveness */
.table-container {
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    margin-bottom: 16px;
    max-width: 100vw;
    -webkit-overflow-scrolling: touch;
}

table {
    border-collapse: collapse;
    width: 100%;
    min-width: 600px;
    font-size: 16px;
    white-space: nowrap;
    table-layout: fixed;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

th, td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
    width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    max-width: 120px;
    font-family: var(--font-field);
}
/* Manual Analysis table overrides: allow wrapping with horizontal scroll */
#sheet-table .table-container { overflow-x: auto; overflow-y: visible; position: relative; }
#sheet-table table { table-layout: auto; white-space: normal; min-width: 900px; border-collapse: separate; border-spacing: 0; }
#sheet-table table th, #sheet-table table td { width: auto; max-width: none; overflow: visible; text-overflow: clip; }
#sheet-table table th { white-space: normal; word-break: normal; overflow-wrap: normal; line-height: 1.3; }
#sheet-table table td { white-space: nowrap; }
#sheet-table table th, #sheet-table table td { min-width: 140px; }
/* Keep first column sticky behavior consistent (only header's first cell and body first column) */
#sheet-table .table-container thead tr:first-child > th:first-child { position: sticky; left: 0; z-index: 5; background: #f5f5f5; }
#sheet-table .table-container tbody td:first-child { position: sticky; left: 0; z-index: 2; background: #fff; }
#sheet-table .table-container table tr:nth-child(even) td:first-child { background: #f7f7f7; }
#sheet-table .table-container table tr:hover td:first-child { background: #eee; }

th {
    background: #f5f5f5;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 4;
    font-size: 16px;
}

tr:nth-child(even) { background: #f7f7f7; }
tr:hover { background: #eee; }

/* Sticky first column (ticker) during horizontal scroll */
.table-container thead tr:first-child > th:first-child { position: sticky; left: 0; z-index: 5; background: #f5f5f5; }
.table-container tbody td:first-child { position: sticky; left: 0; z-index: 2; background: #fff; }
.table-container table tr:nth-child(even) td:first-child { background: #f7f7f7; }
.table-container table tr:hover td:first-child { background: #eee; }
/* Continuous divider to the right of the sticky first column (spans full table height) */
.table-container thead tr:first-child > th:first-child,
.table-container tbody td:first-child { box-shadow: none; border-right: 3px solid #bbb; }

/* Make header cells sticky in Analysis tables */
#sheet-table .table-container thead th { position: sticky; z-index: 4; background: #f5f5f5; }
/* Top header row: center aligned and no wrapping on Analysis tables */
#sheet-table .table-container thead tr:first-child th { text-align: center; white-space: nowrap; top: 0; }
#sheet-table .table-container thead tr:first-child th br { display: none; }

/* Lower header row: wrap between words only, no mid-word breaks */
#sheet-table .table-container thead tr:nth-child(2) th {
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: normal;
    hyphens: none;
    top: var(--thead-row1-h, 32px);
}
#sheet-table .table-container thead tr:nth-child(2) th br { display: none; }

/* Visual dividers between grouped header columns */
#sheet-table .table-container thead tr:first-child th { border-bottom-width: 2px; }
#sheet-table .table-container thead tr:nth-child(2) th.group-end { border-right-width: 3px; border-right-color: #bbb; }
#sheet-table .table-container thead tr:first-child th.group-end { border-right-width: 3px; border-right-color: #bbb; }

/* Extend group boundary divider through body cells */
#sheet-table .table-container tbody td.group-end { border-right-width: 3px; border-right-color: #bbb; }

/* Allow field names to wrap in first column for stock tables */
.kv-table,
.metric-table {
    table-layout: auto;
    white-space: normal;
}
.kv-table th:first-child,
.kv-table td:first-child,
.metric-table th:first-child,
.metric-table td:first-child {
    white-space: normal;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

/* Metric tables on stock page (gain/confidence) */
.metric-table th.gain { background: rgba(111,191,115,0.12); }
.metric-table th.conf { background: #f5f2ff; }
.metric-table td.gain-cell { background: rgba(111,191,115,0.08); }
.metric-table td.conf-cell { background: #faf8ff; }

/* Ensure main content doesn't overflow */
main {
    padding: 16px;
    overflow-x: auto;
    max-width: 100vw;
}

.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#stock-actions { display: flex; align-items: center; gap: 8px; }
.action-btn { background: var(--color-primary); color: #fff; border: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.action-btn.secondary { background: var(--color-accent); color: #fff; border: 1px solid var(--color-accent); }
.action-dropdown { position: relative; display: inline-block; }
.wl-controls .action-dropdown:first-child .action-menu { left: 0; right: auto; }
.wl-controls .action-dropdown:last-child .action-menu { right: 0; left: auto; }
.action-menu { max-width: 90vw; }
.action-menu { position: absolute; top: 100%; right: 0; background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 10px; z-index: 1000; box-shadow: 0 2px 8px rgba(0,0,0,0.12); min-width: 240px; display: none; }
.action-menu.open { display: block; }
.action-menu .row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.action-menu label { font-size: 12px; color: #666; display: block; }
.action-menu input { width: 100%; box-sizing: border-box; height: 34px; }
.action-menu .menu-actions { display: flex; justify-content: flex-end; gap: 8px; }
.action-menu .error { color: #c62828; font-size: 12px; margin-bottom: 6px; }

/* Manual Analysis filter actions: position dropdowns above buttons */
.filter-actions { position: relative; }
#save-filter-menu, #load-filter-menu { top: auto; bottom: 100%; right: 0; margin-bottom: 6px; }

/* Center auth cards while keeping title left-aligned */
.auth-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 16px;
}

/* Center page titles on auth pages only */
.auth-page .page-title-center {
    text-align: center;
}

/* Stack input under label headings */
.form-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-label {
    font-weight: 600;
    font-family: var(--font-field);
}

.auth-form {
    width: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body { font-size: 14px; }
    header { font-size: 16px; grid-template-columns: 1fr; grid-auto-rows: auto; align-items: stretch; gap: 8px; }
    header > nav { grid-column: 1; justify-self: stretch; }
    header > .site-logo { justify-self: center; }
    /* Stack and wrap header nav to avoid overlap */
    header nav { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
    nav a { font-size: 14px; margin-right: 0; padding: 6px 8px; }
    .dropdown-toggle { margin-right: 0; padding: 6px 8px; }
    /* Make dropdown menus full-width and non-overlapping on mobile */
    .dropdown { width: 100%; text-align: center; }
    .dropdown-menu { position: static; min-width: 0; width: 100%; box-shadow: none; border-radius: 6px; }
    /* Hide long brand text to reduce crowding */
    .site-logo .brand-text { display: none; }
    /* Ensure search spans full width below nav */
    .search-container { grid-column: 1 / -1; margin: 8px 0; }
    /* Place any header badges centered on their own row */
    .header-badges { grid-column: 1; justify-self: center; }
    button { font-size: 14px; }
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }

    .site-logo img { height: 34px; }
    .home-hero img { max-width: 190px; width: 68%; }

    th, td {
        width: 100px;
        max-width: 100px;
        padding: 6px 8px;
        font-size: 14px;
    }
    th {
        font-size: 14px;
    }
}
.tab {
    display: inline-block;
    padding: 10px 16px;
    border: 1px solid #ddd;
    margin-right: 8px;
    cursor: pointer;
    font-size: 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.tab.active { background: var(--color-primary); color: #fff; }

/* Search functionality */
.search-container { position: relative; display: flex; align-items: center; gap: 8px; margin: 8px 16px; grid-column: 1 / -1; }
.search-container.moved-below { margin-top: 8px; }

.header-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.logout-btn { background: #c62828; color: #fff; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; }
.logout-btn:hover { background: #b71c1c; }

.profile-welcome { text-align: center; margin: 8px 0 16px; font-size: 18px; font-weight: 500; }
.muted { color: #666; font-size: 13px; }

.wl-controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin: 8px 0 10px; }
.wl-controls > .buy-btn { justify-self: start; }
.wl-controls > .input-with-dropdown { justify-self: end; }
#wl-folder-tabs { display: flex; justify-content: center; }

#stock-search {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
}

.search-button {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    color: #000 !important;
}

.search-dropdown div {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    color: #000 !important;
}

.search-dropdown div:hover {
    background: #f5f5f5;
}

/* Typeahead for watchlist input */
.input-with-dropdown { position: relative; display: inline-block; }
.typeahead-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}
.typeahead-dropdown div { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid #eee; }
.typeahead-dropdown div:hover { background: #f5f5f5; }

/* Watchlist chips and price info */
.watch-item { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.watch-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.chip {
    display: inline-block;
    background: var(--color-secondary);
    color: #0c1222;
    border: 1px solid var(--color-secondary);
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.price-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px 16px;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 8px 12px;
    width: 100%;
    align-items: start;
}
.span-all { grid-column: 1 / -1; }
.price-top { display: flex; justify-content: flex-start; }
.price-controls { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.price-controls .view-btn { margin-left: auto; background: var(--color-primary); color: #fff; border: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.price-controls .wl-remove { background: #f0f0f0; color: #333; border: 1px solid #ddd; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.price-controls .more-btn { background: var(--color-primary); color: #fff; border: none; padding: 6px 10px; border-radius: 4px; cursor: pointer; }
.see-more {
    display: flex;
    justify-content: flex-end;
    margin-top: 6px;
}
.see-more.in-box { grid-column: 1 / -1; }
.see-more button {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}
.more-panel {
    margin-top: 8px;
    border: 1px dashed #ccc;
    border-radius: 6px;
    padding: 8px 10px;
    display: none;
}
.more-panel.in-box { grid-column: 1 / -1; }
.collections-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.collection-card { background: #fff; border: 1px solid #e2e2e2; border-radius: 8px; padding: 10px 12px; }
.bubble-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; align-items: start; }
.table-bubble { background: #ffffff; border: 1px solid var(--color-secondary); border-radius: 10px; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.table-bubble .bubble-title { font-weight: 700; margin-bottom: 6px; color: var(--color-primary); }
.table-bubble .bubble-table-wrap { overflow-x: auto; }
.table-bubble .mini-table { width: 100%; min-width: 0; table-layout: auto; font-size: 14px; }
.table-bubble .mini-table th, .table-bubble .mini-table td { width: auto; max-width: none; padding: 6px 8px; }
.priority-list { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.kv-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px 16px; margin: 6px 0 10px; }
.kv-row { background: #fff; border: 1px solid #e2e2e2; border-radius: 6px; padding: 6px 10px; }
.kv-k { display: block; color: #666; font-size: 12px; margin-bottom: 2px; font-family: var(--font-field); font-weight: 400; }
.kv-v { display: block; color: #111; font-size: 14px; font-weight: 300; word-break: break-word; font-family: var(--font-value); }
.more-panel.open { display: block; }
.collection-name { font-weight: 700; margin-top: 8px; }
.doc-json { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace; font-size: 13px; white-space: pre-wrap; word-break: break-word; background: #f7f7f7; border: 1px solid #e2e2e2; border-radius: 6px; padding: 8px; }
.price-kv { color: #333; }
.price-kv .k { color: #666; font-size: 13px; display: block; font-family: var(--font-field); font-weight: 400; }
.price-kv .v { font-size: 16px; font-weight: 300; font-family: var(--font-value); }

/* Filters */
.filters-container {
    margin: 20px 0;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

/* Make only the Pattern Columns pane scrollable; keep Pattern Filters fixed */
.filters-container .column-selector {
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-tabs {
    display: flex;
    gap: 8px;
    margin: 8px 0 12px;
}
.filter-tab {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
}
.filter-tab.active {
    background: var(--color-primary);
    color: #fff;
}
.pattern-tab {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.pattern-tab.active { background: var(--color-primary); color: #fff; }
.hidden { display: none !important; }

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

/* Allow long pattern tab lists to scroll while keeping filter inputs visible */
#pattern-tabs {
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.filters-toggle {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
}

.filter-group h3 {
    margin-top: 0;
    color: #333;
}

.filter-controls {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    cursor: pointer;
}

.column-selector h4 {
    margin-bottom: 8px;
    color: #555;
}

#column-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.column-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    background: white;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}

.column-toggle:hover {
    background: #f0f0f0;
}

.column-toggle input {
    margin: 0;
}

/* Tab-level show/hide toggle styling */
/* Compact checkbox to the right of tab name */
.tab-toggle { position: relative; width: 16px; height: 16px; border: 1px solid #bbb; border-radius: 3px; background: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.tab-toggle input { display: none; }
.tab-toggle.checked { background: var(--color-primary); border-color: var(--color-primary); }
.tab-toggle.checked::after { content: '✓'; color: #fff; font-size: 12px; line-height: 1; }
.tab-toggle:not(.checked)::after { content: ''; }
.tab-toggle:hover { box-shadow: 0 0 0 2px rgba(30,58,125,0.15); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.grid#vp-view, .grid#vp-edit { grid-template-columns: 1fr; }
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.technical-section { grid-column: 1; }
.fundamental-section { grid-column: 2; display: flex; flex-direction: column; gap: 16px; }
.card { border: 1px solid #e2e2e2; border-radius: 8px; padding: 12px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
/* Centered container for payment buttons */
.buy-center { display: flex; justify-content: center; align-items: center; margin: 8px 0; }
/* Collapsible card header */
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px -4px 8px -4px; padding: 4px; }
.card-header h3 { margin: 0; font-size: 18px; }
.collapse-btn { background: transparent; border: none; font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; color: #333; }
.collapse-btn:hover { background: #f5f5f5; border-radius: 4px; }
.card.collapsed > :not(.card-header) { display: none !important; }

/* Stock page two-column layout */
.stock-layout { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: start; }
.stock-layout .left-col { display: flex; flex-direction: column; gap: 16px; }
.stock-layout .right-col { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.ai-tech-predictions-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* Fundamental pair side-by-side */
.fund-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
	.fund-pair { grid-template-columns: 1fr; }
}
/* Light, non red/green tints for quarterly/yearly */
.fund-q-card { background: #f7fbff; }
.fund-y-card { background: #fff9f2; }

/* Condense fundamental cards to content width */
.fund-q-card,
.fund-y-card,
.fund-fused-card,
.stock-summary-card { display: block; width: 480px; align-self: flex-start; }
.fund-q-card .table-container,
.fund-y-card .table-container { width: 100%; max-width: 100%; display: block; overflow-x: visible; }
.fund-q-card table,
.fund-y-card table { min-width: 0; width: 100%; table-layout: auto; }
.fund-q-card th, .fund-q-card td,
.fund-y-card th, .fund-y-card td { width: auto; max-width: none; }
@media (max-width: 1024px) {
	.stock-layout { grid-template-columns: 1fr; }
}

/* Profile tabs */
.tabs { display: flex; gap: 8px; margin: 12px 0; }
.tabs.center { justify-content: center; }
.card .tabs#ai-preds-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
.card .tabs#ai-preds-tabs .tab-btn { width: 100%; }
/* AI Technical custom tabs */
.ai-bias-tabs, .ai-days-tabs, .ai-variant-tabs { display: grid; gap: 8px; width: 100%; margin: 8px 0; }
.ai-bias-tabs { grid-template-columns: repeat(2, 1fr); }
.ai-days-tabs { grid-template-columns: repeat(4, 1fr); }
.ai-variant-tabs { grid-template-columns: repeat(2, 1fr); }
.ai-bias-tabs .ai-bias-tab, .ai-days-tabs .ai-day-tab, .ai-variant-tabs .ai-variant-tab { width: 100%; padding: 10px 12px; border: 1px solid #ddd; background: #fff; border-radius: 4px; cursor: pointer; font-size: 16px; }
.ai-bias-tabs .ai-bias-tab.active, .ai-days-tabs .ai-day-tab.active, .ai-variant-tabs .ai-variant-tab.active { background: var(--color-primary); color: #fff; }
.tab-btn { padding: 8px 12px; border: 1px solid #ddd; background: #fff; border-radius: 4px; cursor: pointer; }
.tab-btn.active { background: var(--color-primary); color: #fff; }
.learning-layout #learning-page-list .tab-btn.active { background: var(--color-header); color: #fff; border-color: var(--color-header); }
.tab-btn.locked { opacity: 0.6; cursor: not-allowed; position: relative; }
.tab-btn.locked:hover::after {
	content: attr(title);
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	bottom: -34px;
	white-space: nowrap;
	background: rgba(0,0,0,0.85);
	color: #fff;
	padding: 4px 8px;
	border-radius: 4px;
	font-size: 12px;
	pointer-events: none;
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }
/* Variant tabs and panes within AI technical blocks on stock page */
.variant-tabs { display: flex; gap: 8px; margin: 8px 0; }
.variant-pane { display: none; }
.variant-pane.active { display: block; }
/* Variant tabs inserted under the chart within each Top 10 box */
.variant-tabs { margin-top: 6px; }
/* Stock page tab tweaks */
#stock-tabs { margin-top: 16px; }
.tabset { margin-top: 8px; }
.buy-btn { background: var(--color-bull); color: #fff; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; }
.sell-btn { background: var(--color-bear); color: #fff; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; }
.buy-btn:active, .sell-btn:active { transform: scale(0.98); transition: transform 0.08s ease; }
.buy-btn:disabled, .sell-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.button-loading { position: relative; padding-right: 30px; }
.button-loading::after {
    content: "";
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.9);
    border-top-color: transparent;
    border-radius: 50%;
    position: absolute;
    right: 8px;
    top: 50%;
    margin-top: -7px;
    animation: btnspin 0.8s linear infinite;
}
@keyframes btnspin { to { transform: rotate(360deg); } }
.tracking-row { display: grid; grid-template-columns: 1fr 160px 160px auto auto; gap: 8px; align-items: stretch; margin-top: 8px; }
.tracking-row input { height: 38px; }
.input-with-dropdown { margin: 0; }
.tracking-row label { display: flex; align-items: center; gap: 8px; }

/* Portfolio summary metrics */
#pt-summary { margin: 8px 0; }
.pt-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.pt-metric { background: #fff; border: 1px solid #e2e2e2; border-radius: 6px; padding: 8px 10px; }
.pt-label { color: #666; font-size: 12px; margin-bottom: 2px; }
.pt-value { font-size: 18px; font-weight: 700; }
.pt-metric.gain-up .pt-value { color: var(--color-bull); }
.pt-metric.gain-down .pt-value { color: var(--color-bear); }
.pt-metric.gain-flat .pt-value { color: #333; }

/* Pie chart title and tooltip */
.portfolio-chart .chart-title { text-align: left; font-weight: 600; margin-bottom: 6px; }
.chart-tooltip {
    position: absolute;
    padding: 6px 8px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 12px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    transform: translate(-50%, -120%);
}

/* Inline dynamic filters with wrapping */
#dynamic-filters {
    display: block;
}
#dynamic-filters .filter-table { width: 100%; min-width: 0; table-layout: auto; font-size: 14px; }
#dynamic-filters .filter-table th, #dynamic-filters .filter-table td { padding: 6px 8px; border: 1px solid #e0e0e0; }
#dynamic-filters .filter-table thead th { background: #fafafa; font-weight: 600; text-align: left; }
#dynamic-filters .filter-table .field-label { width: 40%; word-break: break-word; }
#dynamic-filters .filter-table select { width: 100%; box-sizing: border-box; }
#dynamic-filters .filter-table input[type="number"] { width: 100%; box-sizing: border-box; }
#dynamic-filters .table-value-group { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }

/* Form elements */
input, select, textarea {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

input[type="number"] {
    width: 100px;
}

/* Filter action buttons bottom-right */
/* Place filter actions in header at top-right */
.filter-actions { display: flex; align-items: center; gap: 10px; margin: 0; }
.filter-actions .run-filter {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
}
.filter-actions .clear-filter {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 4px;
}

/* Links and interactive elements */
a {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* List items */
li {
    font-size: 16px;
    line-height: 1.5;
}

/* Expand chart to fill remaining space */
#tradingview-widget { width: 100% !important; }


.site-footer { margin-top: 24px; padding: 16px; text-align: center; background: #f7f7f7; border-top: 1px solid #e2e2e2; }
.site-footer .footer-logo img { height: 42px; width: auto; }
.site-footer .footer-disclaimer { color: #555; font-size: 13px; max-width: 900px; margin: 8px auto 0; line-height: 1.5; }

/* Cookie banner */
.cookie-banner {
    position: fixed;
    z-index: 5000;
    left: 16px;
    right: 16px;
    bottom: 16px;
    background: #ffffff;
    border: 1px solid var(--color-neutral);
    border-left: 6px solid var(--color-neutral);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}
.cookie-banner .cookie-content { display: flex; gap: 16px; padding: 14px 16px; align-items: flex-start; }
.cookie-banner .cookie-icon { font-size: 24px; line-height: 1; }
.cookie-banner .cookie-text { flex: 1 1 auto; color: #0c1222; }
.cookie-banner .cookie-title { margin: 0 0 4px 0; font-size: 16px; font-weight: 700; }
.cookie-banner .cookie-desc { margin: 0 0 4px 0; }
.cookie-banner .cookie-list { margin: 4px 0 6px 18px; padding: 0; }
.cookie-banner .cookie-note { margin: 6px 0 0 0; font-size: 13px; color: #333; }
.cookie-banner .cookie-actions { display: flex; gap: 8px; align-self: center; }
.cookie-btn { background: var(--color-primary); color: #fff; border: none; padding: 8px 12px; border-radius: 999px; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
.cookie-btn.secondary { background: #fff; color: #0c1222; border: 1px solid var(--color-neutral); }
@media (max-width: 640px) {
    .cookie-banner .cookie-content { flex-direction: column; align-items: stretch; }
    .cookie-banner .cookie-actions { justify-content: flex-end; }
}
