/* Theme colours for every page. Change --accent to rebrand: the hover (--accent-h) and tint (--accent-d)
   shades are derived from it. --red is separate and stays for deletes, losses and errors. */
:root {
    --bg: #f4f4f0;
    --surface: #ffffff;
    --surface2: #f8f8f5;
    --border: #e5e5df;
    --border2: #d0d0c8;
    --text: #1a1a1a;
    --text2: #4a4a4a;
    --muted: #888880;
    --accent: #c9a84c;
    --accent-h: color-mix(in srgb, var(--accent) 85%, black);
    --accent-d: color-mix(in srgb, var(--accent) 10%, transparent);
    --green: #16a34a;
    --green-d: rgba(22, 163, 74, 0.08);
    --red: #dc2626;
    --red-h: #b91c1c;
    --red-d: rgba(220, 38, 38, 0.08);
    --blue: #2563eb;
    --violet: #7c3aed;
    --nav-h: 54px;
    --sidebar-w: 210px;
}

body {
    font-family: 'Poppins', sans-serif;
}

#portfolio tr th, #portfolio tr td {
    text-align: right;
}

#portfolio tr th, #portfolio tr td {
    padding: 2px;
}

/* ---- app layout (moved from templates/layout.html) ---- */

body {
    font-family: 'Lexend', sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a {
    text-decoration: none;
    color: inherit;
}

a:hover {
    text-decoration: underline;
}

.text-primary {
    background-color: #fff !important;
    color: var(--accent) !important;
}

.btn-primary {
    background-color: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
    font-weight: 600;
    font-size: 12px;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--accent-h) !important;
    border-color: var(--accent-h) !important;
}

.btn-danger {
    background-color: var(--red) !important;
    border-color: var(--red) !important;
    color: #fff !important;
    font-weight: 600;
    font-size: 12px;
}

.btn-danger:hover, .btn-danger:focus {
    background-color: var(--red-h) !important;
    border-color: var(--red-h) !important;
}

.btn-outline-secondary {
    border-color: var(--border2);
    color: var(--text2);
    font-size: 12px;
    font-weight: 500;
}

.btn-outline-secondary:hover {
    background: var(--surface2);
    color: var(--text);
}

.card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 18px;
    font-weight: 700;
    font-size: 13px;
    border-radius: 12px 12px 0 0 !important;
}

.card-body {
    padding: 16px 18px;
}

.card-footer {
    background: var(--surface2);
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--muted);
}

.badge {
    font-family: 'Lexend', sans-serif;
    font-weight: 600;
}

.topnav {
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brand {
    font-weight: 800;
    font-size: 15px;
    letter-spacing: -0.4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-mark {
    min-width: 24px;
    height: 24px;
    padding: 0 5px;
    letter-spacing: 0.3px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
}

.nav-link-custom {
    padding: 5px 12px;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.14s ease;
}

.nav-link-custom:hover {
    color: var(--text2);
    background: var(--surface2);
}

.nav-link-custom.active {
    color: var(--text);
    background: var(--surface2);
    font-weight: 600;
}

/* header portfolios dropdown */
.portfolio-toggle[aria-expanded="true"] {
    color: var(--text);
    background: var(--surface2);
}

.portfolio-count {
    font-size: 10px;
    font-weight: 600;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 999px;
    background: var(--accent-d);
    color: var(--accent-h);
}

.portfolio-caret {
    font-size: 10px;
    transition: transform 0.15s ease;
}

.portfolio-toggle[aria-expanded="true"] .portfolio-caret {
    transform: rotate(180deg);
}

.portfolio-menu {
    width: 270px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    max-height: 70vh;
    overflow-y: auto;
}

.portfolio-menu-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    padding: 6px 8px 4px;
}

.portfolio-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px;
    border-radius: 7px;
    color: var(--text);
    text-decoration: none;
}

.portfolio-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.portfolio-item.current {
    background: var(--accent-d);
}

.portfolio-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text2);
}

.portfolio-item.current .portfolio-avatar {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.portfolio-item-name {
    font-size: 13px;
    font-weight: 600;
}

.portfolio-item-meta {
    font-size: 11px;
    color: var(--muted);
}

.portfolio-check {
    color: var(--accent-h);
    font-size: 16px;
}

.portfolio-empty {
    font-size: 12px;
    color: var(--muted);
    padding: 8px;
}

.portfolio-menu-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.portfolio-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 8px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    text-decoration: none;
}

.portfolio-action:hover {
    background: var(--surface2);
    color: var(--text);
}

.portfolio-action .bi-plus-lg {
    color: var(--accent-h);
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px 10px;
    position: sticky;
    top: var(--nav-h);
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    flex-shrink: 0;
}

.sb-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--muted);
    text-transform: uppercase;
    display: block;
    padding: 8px 8px 5px;
}

.sb-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 8px;
    color: var(--text2);
    font-size: 12px;
    font-weight: 500;
    transition: all 0.14s;
    position: relative;
}

.sb-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.sb-item.active {
    background: var(--surface2);
    color: var(--text);
    font-weight: 600;
}

.sb-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 55%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.sb-badge {
    margin-left: auto;
    background: var(--bg);
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.sb-add {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 8px;
    margin: 4px 0;
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    border: 1px dashed var(--border2);
    transition: all 0.14s;
}

.sb-add:hover {
    background: var(--accent-d);
    border-color: var(--accent);
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.sc {
    padding: 15px 18px;
    border-right: 1px solid var(--border);
}

.sc:last-child {
    border-right: none;
}

.sc-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 7px;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.sc-value {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.6px;
    margin-bottom: 3px;
}

.sc-sub {
    font-size: 11px;
    font-weight: 600;
}

.up {
    color: var(--green) !important;
}

.down {
    color: var(--red) !important;
}

.neu {
    color: var(--muted);
}

.p-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    display: block;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}

.p-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
    transform: translateY(-1px);
    border-color: var(--border2);
}

.p-card-stripe {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.p-card-value {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.6px;
    margin: 10px 0 4px;
}

.p-card-meta {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 10px;
}

.p-card-stat {
    font-size: 11px;
    color: var(--muted);
}

.p-card-stat span {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    margin-top: 1px;
}

.alloc-bar {
    height: 3px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    background: var(--bg);
    margin-top: 10px;
}

.alloc-seg {
    height: 100%;
}

.p-card-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    border-style: dashed;
    color: var(--muted);
    gap: 6px;
}

.p-card-add:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-d);
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
}

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

.legend-label {
    flex: 1;
    color: var(--text2);
    font-weight: 500;
}

.legend-val {
    font-size: 11px;
    color: var(--muted);
    min-width: 60px;
    text-align: right;
}

.legend-pct {
    font-weight: 700;
    font-size: 12px;
    min-width: 38px;
    text-align: right;
}

.mover-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.mover-row:last-child {
    border-bottom: none;
}

.mover-logo {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    flex-shrink: 0;
}

.mover-info {
    flex: 1;
}

.mover-sym {
    font-weight: 700;
    font-size: 12px;
}

.mover-exch {
    font-size: 10px;
    color: var(--muted);
}

/* page controls on list pages */
.pagination .page-link {
    color: var(--text2);
    border-color: var(--border);
}

.pagination .page-item.active .page-link {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* stock names that open the stock's page in its portfolio */
a.stock-link,
.holdings-table td a.stock-link {
    color: inherit;
    text-decoration: none;
}

a.stock-link:hover,
.holdings-table td a.stock-link:hover {
    color: var(--accent-h);
    text-decoration: none;
}

.mover-portfolio {
    font-weight: 400;
    color: var(--muted);
    text-decoration: none;
}

.mover-portfolio:hover {
    color: var(--accent-h);
}

.mover-chg {
    font-size: 12px;
    font-weight: 700;
}

.act-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.act-row:last-child {
    border-bottom: none;
}

.act-badge {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}

.act-badge.buy {
    background: var(--green-d);
    color: var(--green);
}

.act-badge.sell {
    background: var(--red-d);
    color: var(--red);
}

.act-pill {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    margin-right: 4px;
    vertical-align: 1px;
}

/* money going out (buy) is red, coming in (sell) is green */
.act-pill.buy {
    background: var(--red-d);
    color: var(--red);
}

.act-pill.sell {
    background: var(--green-d);
    color: var(--green);
}

.act-amount.buy {
    color: var(--red);
}

.act-amount.sell {
    color: var(--green);
}

.act-meta {
    flex: 1;
}

.act-title {
    font-size: 12px;
    font-weight: 400;
}

.act-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}

.act-val {
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
    text-align: right;
}

.dropdown-menu {
    font-size: 13px;
    min-width: 190px;
}

.ticker-logo {
    width: 32px;
    height: 32px;
}

.ticker-name {
    font-weight: 700;
    font-size: 12px;
    letter-spacing: -0.3px;
}

.holdings-table {
    font-size: 12px;
}

.portfolio-overview-table {
    font-size: 14px;
}

.portfolio-overview-table .portfolio-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
}

.sparkline {
    display: block;
    overflow: visible;
}

.holdings-table th:first-child,
.holdings-table td:first-child {
    padding-left: 1.2rem;
}

.holdings-table th:last-child,
.holdings-table td:last-child {
    padding-right: 1.2rem;
}

.holdings-table td a {
    text-decoration: none;
    color: var(--blue);
}

.holdings-table td a:hover {
    text-decoration: underline;
}

.card-body > a:hover {
    text-decoration: underline;
}

button.nav-link-custom {
    background: none;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
}

@media (max-width: 960px) {
    .sidebar {
        display: none;
    }
}

@media (max-width: 700px) {
    .summary-strip,
    .summary-strip[data-scope] {
        grid-template-columns: 1fr 1fr !important;
    }
}

.scope-switch .btn {
    font-size: 11px;
    padding: 2px 10px;
}

/* dividend status badge (holding and dividends pages) */
.badge-confirmed {
    background: var(--green-d);
    color: var(--green);
    border: 1px solid var(--green-d);
}

/* estimated dividends waiting to be confirmed (portfolio page) */
.to-confirm {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 4px;
    padding: 0 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    background: var(--accent-d);
    color: var(--accent-h) !important;
    text-decoration: none !important;
}

.to-confirm-note {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-d);
    color: var(--accent-h);
}

.privacy-toggle {
    font-size: 11px;
    padding: 2px 10px;
}

.privacy-toggle.active {
    background: var(--surface2) !important;
    color: var(--text) !important;
}

.scope-switch .btn.active {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: #fff !important;
}

/* ---- privacy mode (eye toggle in the header): blur cash amounts, keep percentages ---- */
.privacy .money {
    filter: blur(7px);
    user-select: none;
}

.privacy-only {
    display: none;
}

.privacy .privacy-only {
    display: inline;
}
