/* ============================================================
   APP SHELL — sidebar + topbar, adapted from the Wealthsmith reference
============================================================ */

.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* Sidebar */

.sidebar {
    background: var(--surface-glass);
    backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
    -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 0 20px 18px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 18px;
    box-shadow: var(--shadow-blue);
    flex-shrink: 0;
    position: relative;
}

.brand-mark::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), transparent 60%);
}

.brand-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
}

.brand-name span {
    color: var(--accent);
}

.brand-tag {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    margin-top: 2px;
    font-weight: 500;
}

.nav-section {
    padding: 14px 20px 6px;
    font-size: 10.5px;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 1px 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    opacity: 0.75;
    font-size: 13.5px;
    cursor: pointer;
    position: relative;
    transition: background 0.15s var(--ease), color 0.15s var(--ease), opacity 0.15s var(--ease);
    font-weight: 500;
    text-decoration: none;
    width: calc(100% - 24px);
    background: none;
    border: none;
    text-align: left;
    font-family: inherit;
}

.nav-item:hover {
    background: var(--bg-2);
    opacity: 1;
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent-dim);
    font-weight: 600;
    opacity: 1;
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-item .ico {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.15s var(--ease);
}

.nav-item:hover .ico {
    transform: translateX(1px);
}

.sidebar-footer {
    padding: 16px 0 8px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 20px 12px;
}

.sidebar-user-info {
    min-width: 0;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-email {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-item:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* Main + topbar */

.main {
    background: var(--bg);
    min-height: 100vh;
    /* grid items default to min-width:auto, which lets a wide child (e.g. the
       holdings table) force this whole column — and the page — wider than the
       viewport ("grid blowout"). min-width:0 lets it shrink properly so inner
       scroll containers (like .table-wrapper) do the scrolling instead. */
    min-width: 0;
}

.password-nudge {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 32px;
    background: var(--accent-soft);
    border-bottom: 1px solid var(--accent-border);
    font-size: 13px;
    color: var(--accent-dim);
}

.password-nudge-link {
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    white-space: nowrap;
}

.password-nudge-link:hover {
    text-decoration: underline;
}

.password-nudge-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--accent-dim);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    flex-shrink: 0;
}

.password-nudge-dismiss:hover {
    color: var(--accent);
}

@media (max-width: 640px) {
    .password-nudge {
        padding: 10px 16px;
        flex-wrap: wrap;
    }
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--overlay-blur);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    position: sticky;
    top: 0;
    z-index: 30;
}

.crumb {
    flex: 1;
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.icon-btn, .theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    flex-shrink: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}

button.icon-btn:hover, button.theme-toggle:hover {
    background: var(--bg-2);
    color: var(--text);
    box-shadow: none;
}

.icon-btn svg, .theme-toggle svg {
    width: 17px;
    height: 17px;
}

.theme-toggle .icon-moon {
    display: none;
}

.theme-toggle.is-dark .icon-sun {
    display: none;
}

.theme-toggle.is-dark .icon-moon {
    display: block;
}

.crumb b {
    color: var(--text);
    font-weight: 600;
}

/* Topbar's signed-out Sign in / Create account pair (base.html's
   .topbar-actions {% else %} branch, shown on the now-public Markets/asset
   pages). Not .auth-btn (login.css) on purpose -- that stylesheet isn't
   loaded here, and its own .theme-toggle sizing would otherwise collide
   with this file's .theme-toggle rule above. */
.topbar-auth-btn {
    display: inline-flex;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border-2);
    background: var(--surface);
    transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.topbar-auth-btn:hover { background: var(--bg-2); }
.topbar-auth-btn--primary {
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
}
.topbar-auth-btn--primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }

/* Alerts bell + dropdown */

.alert-wrap {
    position: relative;
}

.alert-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-width: calc(100vw - 32px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    z-index: 50;
    animation: alert-panel-in 0.15s var(--ease);
}

.alert-panel.hidden {
    display: none;
}

/* Phones/tablets: the topbar centres its items, so a panel anchored to the bell's right edge
   hangs off-screen. Anchor to the (sticky) topbar instead and span the viewport with a gutter. */
@media (max-width: 860px) {
    .alert-wrap {
        position: static;
    }

    .alert-panel {
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        top: calc(100% + 8px);
        padding: 14px;
    }

    #unified-alert-rows {
        max-height: calc(100vh - 220px);
        max-height: calc(100dvh - 220px);
    }
}

@keyframes alert-panel-in {
    from { opacity: 0; transform: translateY(4px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.alert-panel-header {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.alert-panel-greeting {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 14px;
}

.alert-row {
    display: flex;
    gap: 10px;
    padding: 10px 0;
}

.alert-row + .alert-row {
    border-top: 1px solid var(--border);
}

.alert-row-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.alert-row-icon svg {
    width: 17px;
    height: 17px;
}

.alert-row-icon-ai {
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    color: #fff;
}

.alert-row-icon-human {
    background: var(--bg-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.alert-row-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.alert-row-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent-dim);
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-full);
    padding: 1px 7px;
}

.alert-row-text {
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.5;
}

.alert-row-time {
    font-size: 11px;
    color: var(--text-faint);
    margin-top: 3px;
}

/* Advisor advice unread state -- a subtle accent-tinted left rule, not a
   full-block highlight (matches the app-wide "text color, not a shaded
   block" hover convention already established elsewhere). */
.alert-row-unread {
    position: relative;
    padding-left: 8px;
    margin-left: -8px;
}

.alert-row-unread::before {
    content: "";
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 2px;
    border-radius: var(--radius-full);
    background: var(--accent);
}

.alert-panel-divider {
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* Unified bell feed (advice + Richie insights, merged by timestamp) --
   the panel scrolls once there's more than a handful of rows, and a day
   label separates groups instead of the old two-stacked-sections layout. */
#unified-alert-rows {
    max-height: 360px;
    overflow-y: auto;
}

.alert-day-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    margin: 12px 0 2px;
}

.alert-day-label:first-child {
    margin-top: 0;
}

.alert-panel-footer {
    display: block;
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}

.alert-panel-footer:hover {
    color: var(--accent-dim);
}

/* Bell-icon unread count badge */
.icon-btn {
    position: relative;
}

.alert-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border: 2px solid var(--surface);
}

.alert-badge.hidden {
    display: none;
}

.topbar-actions .avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--border-2);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}

.page {
    padding: 28px 32px 60px;
    animation: page-fade-in 0.25s var(--ease);
}

@keyframes page-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    margin-bottom: 26px;
}

.page-title {
    font-size: 27px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.03em;
    line-height: 1.15;
    margin-bottom: 6px;
}

.page-sub {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 640px;
    line-height: 1.55;
}

/* Opt-in extension of .page-header for pages with a top-right primary
   action (Goals' "+ Add Goal", the advisor client page's "+ Give
   Advice") -- global here since multiple pages that don't share a
   common page-specific stylesheet all need it. */
.page-header-with-action {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ============================================================
   MOBILE APP SHELL — below 860px, this stops looking like a website
   with a squeezed-in sidebar and becomes a proper app shell: sidebar
   is gone entirely, replaced by a fixed bottom tab bar (the standard
   native-app navigation pattern), full-bleed content, minimal header.
============================================================ */

.mobile-tabbar {
    display: none;
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .sidebar {
        display: none;
    }

    .topbar {
        padding: 14px 16px;
        justify-content: center;
    }

    .topbar .crumb {
        font-size: 15px;
        font-weight: 700;
        color: var(--text);
    }

    .topbar .crumb b {
        font-weight: 700;
    }

    .topbar-actions {
        display: none;
    }

    .page {
        padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
    }

    .mobile-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 40;
        background: var(--overlay-blur-strong);
        backdrop-filter: blur(20px) saturate(1.4);
        -webkit-backdrop-filter: blur(20px) saturate(1.4);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px -4px rgba(16, 24, 40, 0.06);
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    }

    .tab-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 2px;
        border-radius: var(--radius-md);
        color: var(--text-muted);
        text-decoration: none;
        font-size: 10px;
        font-weight: 600;
        line-height: 1.15;
        text-align: center;
        transition: color 0.15s var(--ease), background 0.15s var(--ease);
        /* .tab-item is also used on a <button> (e.g. mobile logout) — reset
           native button chrome so it matches the <a> tab-items exactly. */
        background: none;
        border: none;
        font-family: inherit;
        cursor: pointer;
    }

    .tab-item .ico {
        width: 22px;
        height: 22px;
    }

    .tab-item.active {
        background: var(--accent-soft);
        color: var(--accent);
    }
}

@media (max-width: 420px) {
    .brand-tag {
        display: none;
    }
}

/* h1 versions of .page-title (SEO headings): same look, no default h1 margins */
h1.page-title { margin-top: 0; }

/* Server-rendered SEO facts on public market pages */
.seo-facts p { color: var(--text-muted); font-size: 14px; line-height: 1.65; max-width: 780px; }
.seo-facts a { color: var(--accent); text-decoration: none; }
.seo-facts a:hover { text-decoration: underline; }
.seo-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 22px; margin: 14px 0; }
.seo-dl div { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.seo-dl dt { font-size: 12px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.seo-dl dd { margin: 2px 0 0; font-weight: 600; word-break: break-word; }
.seo-links { list-style: none; padding: 0; margin: 12px 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 18px; }
.seo-links li a { font-size: 13.5px; font-weight: 600; }
.seo-links li span { color: var(--text-faint); font-weight: 500; }
.seo-note { font-size: 12px !important; color: var(--text-faint) !important; }

/* Topbar trial pill (all pages, for signed-in clients) */
.trial-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; padding: 7px 12px; min-height: 34px;
    border-radius: 999px; text-decoration: none; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent-border); white-space: nowrap; }
.trial-pill:hover { background: var(--accent-border); }
.trial-pill--premium { color: #7a4b00; background: linear-gradient(135deg, #fff3cf, #ffe08a); border-color: #f2c94c; box-shadow: 0 1px 6px rgba(242, 201, 76, .35); }
.trial-pill--premium:hover { background: linear-gradient(135deg, #ffefb8, #ffd85e); }
.trial-pill--premium svg { flex: none; }
:root[data-theme="dark"] .trial-pill--premium { color: #ffd966; background: linear-gradient(135deg, #3b2e0a, #5a4410); border-color: #8a6a14; box-shadow: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .trial-pill--premium { color: #ffd966; background: linear-gradient(135deg, #3b2e0a, #5a4410); border-color: #8a6a14; box-shadow: none; } }
.trial-pill--expired { color: var(--danger-dim); background: var(--danger-soft); border-color: var(--danger-border); }
@media (max-width: 480px) { .trial-pill { padding: 6px 10px; font-size: 11px; } .trial-pill .long { display: none; } }
