/* BoldSage product layer: calm enterprise surfaces with the public brand's science accents. */
:root {
    --bs-cyan: #67e8f9;
    --bs-gold: #e6bd58;
    --bs-ink-deep: #07131c;
    --bs-ink-soft: #17313a;
    --bs-accent: #2f7771;
    --bs-accent-strong: #245e59;
    --bs-focus: rgba(103, 232, 249, .52);
}

body {
    background: var(--page);
    color: var(--ink);
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    text-rendering: optimizeLegibility;
}

.sidebar {
    background: linear-gradient(160deg, var(--bs-ink-deep) 0%, #0c222b 62%, var(--bs-ink-soft) 100%);
    border-right: 1px solid rgba(103, 232, 249, .14);
    box-shadow: 12px 0 32px rgba(2, 4, 10, .08);
}

.brand {
    min-height: 52px;
    margin-bottom: 22px;
}

.brand img {
    box-shadow: 0 0 0 1px rgba(103, 232, 249, .28), 0 8px 20px rgba(2, 4, 10, .22);
}

.brand strong { letter-spacing: .01em; }

.portal-clock {
    border-color: rgba(103, 232, 249, .18);
    background: linear-gradient(135deg, rgba(103, 232, 249, .11), rgba(230, 189, 88, .08));
    box-shadow: inset 0 1px rgba(255, 255, 255, .05);
}

.nav-shell { gap: 5px; }

.nav-summary,
.nav-link {
    transition: background-color .18s ease, color .18s ease, transform .18s ease;
}

.nav-summary:hover,
.nav-link:hover {
    background: rgba(103, 232, 249, .10);
    color: #f8fbff;
}

.nav-summary.active,
.nav-link.active {
    background: rgba(103, 232, 249, .15);
    color: #fff;
    box-shadow: inset 2px 0 var(--bs-cyan);
}

.nav-link.active::before { background: var(--bs-gold); }
.main { min-width: 0; }

.dashboard-app .main {
    background:
        radial-gradient(circle at 100% 0, rgba(103, 232, 249, .055), transparent 24rem),
        var(--page);
}

.dashboard-app .compact-hero {
    border-color: rgba(103, 232, 249, .24);
    background: linear-gradient(115deg, rgba(255, 255, 255, .98), rgba(247, 251, 255, .96) 58%, rgba(238, 250, 250, .92));
    box-shadow: 0 16px 34px rgba(7, 19, 28, .08);
}

.dashboard-app .compact-hero::after {
    background: linear-gradient(90deg, transparent, rgba(103, 232, 249, .46), rgba(230, 189, 88, .42), transparent);
}

.dashboard-app .profile-orb {
    background: linear-gradient(145deg, var(--bs-ink-soft), var(--bs-accent));
    border-color: rgba(103, 232, 249, .34);
    box-shadow: 0 10px 22px rgba(7, 19, 28, .16), 0 0 0 4px rgba(103, 232, 249, .08);
}

.dashboard-app .compact-role strong { color: var(--bs-accent-strong); }

.dashboard-app .compact-directory,
.dashboard-app .tools-panel {
    border-color: rgba(47, 119, 113, .20);
    box-shadow: 0 12px 28px rgba(7, 19, 28, .055);
}

.dashboard-app .tool-link {
    border-color: rgba(47, 119, 113, .18);
    background: rgba(255, 255, 255, .93);
    box-shadow: 0 7px 18px rgba(7, 19, 28, .045);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background-color .18s ease;
}

.dashboard-app .tool-link:hover,
.dashboard-app .tool-link:focus-visible {
    border-color: rgba(103, 232, 249, .70);
    background: #fff;
    box-shadow: 0 12px 24px rgba(7, 19, 28, .10), 0 0 0 3px rgba(103, 232, 249, .10);
    transform: translateY(-2px);
}

.dashboard-app .tool-link::before {
    background: #eef8f7;
    color: var(--bs-accent-strong);
    border: 1px solid rgba(47, 119, 113, .18);
}

.dashboard-app .tool-link span { color: var(--bs-accent-strong); }

.btn {
    transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.btn:hover {
    box-shadow: 0 8px 18px rgba(7, 19, 28, .12);
    transform: translateY(-1px);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--bs-focus-color, var(--bs-accent));
    outline-offset: 2px;
}

.chat-status[data-presence-state="online"] {
    border-color: rgba(63, 125, 85, .35);
    background: #f1f8f0;
    color: #2f5e46;
}

.chat-status[data-presence-state="offline"] {
    border-color: rgba(191, 219, 254, .9);
    background: #eff6ff;
    color: #1e3a8a;
}

.portal-utility {
    position: fixed;
    top: 16px;
    right: 22px;
    z-index: 1120;
    display: flex;
    align-items: center;
    gap: 8px;
}

.portal-utility-button,
.portal-panel-close,
.portal-notification-actions button {
    border: 1px solid rgba(47, 119, 113, .22);
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
    color: var(--bs-ink-soft);
    cursor: pointer;
    font: inherit;
    font-size: .78rem;
    font-weight: 800;
    padding: 9px 11px;
}

.portal-utility-button:hover,
.portal-utility-button:focus-visible,
.portal-panel-close:hover,
.portal-notification-actions button:hover { border-color: var(--bs-accent); background: #fff; }
.portal-utility-button kbd { margin-left: 4px; color: var(--bs-accent-strong); font-size: .66rem; }
.portal-notification-count { display: inline-grid; min-width: 18px; min-height: 18px; place-items: center; margin-left: 3px; border-radius: 999px; background: var(--bs-gold); color: var(--bs-ink-deep); font-size: .66rem; }
.portal-command-backdrop,
.portal-notification-backdrop { position: fixed; inset: 0; z-index: 1130; background: rgba(7, 19, 28, .38); }
.portal-command-palette { position: fixed; top: 12vh; left: 50%; z-index: 1140; width: min(650px, calc(100vw - 28px)); transform: translateX(-50%); padding: 18px; border: 1px solid rgba(47, 119, 113, .24); border-radius: 12px; background: var(--surface); box-shadow: 0 24px 70px rgba(7, 19, 28, .24); }
.portal-command-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.portal-command-head h2 { margin: 4px 0 14px; font-size: 1.25rem; }
.portal-command-palette input { width: 100%; min-height: 46px; margin-bottom: 10px; }
.portal-command-results { display: grid; gap: 5px; max-height: min(55vh, 460px); overflow: auto; }
.portal-command-result { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.portal-command-result:hover, .portal-command-result:focus-visible { background: color-mix(in srgb, var(--surface-soft) 82%, var(--bs-cyan) 18%); outline: none; }
.portal-command-result small { color: var(--muted); font-size: .72rem; }
.portal-notification-center { position: fixed; inset: 0; z-index: 1140; isolation: isolate; }
.portal-notification-panel { position: absolute; top: 70px; right: 22px; z-index: 1; width: min(420px, calc(100vw - 28px)); max-height: calc(100vh - 92px); overflow: auto; padding: 18px; border: 1px solid rgba(47, 119, 113, .24); border-radius: 12px; background: var(--surface); box-shadow: 0 24px 70px rgba(7, 19, 28, .24); filter: none; opacity: 1; pointer-events: auto; }
.portal-notification-actions { display: flex; gap: 8px; justify-content: flex-end; margin: -4px 0 10px; }
.portal-notification-actions button { background: var(--surface-soft); font-size: .72rem; padding: 7px 9px; }
.portal-notification-item { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.portal-notification-item.is-unread { border-left: 3px solid var(--bs-gold); padding-left: 9px; }
.portal-notification-item strong { display: block; font-size: .88rem; }
.portal-notification-item p { margin: 4px 0; color: var(--muted); font-size: .82rem; line-height: 1.4; }
.portal-notification-item small { color: var(--muted); font-size: .7rem; }
.portal-notification-link { align-self: center; color: var(--bs-accent-strong); font-size: .75rem; font-weight: 800; }
.portal-empty-state { display: grid; gap: 5px; padding: 24px 8px; color: var(--muted); text-align: center; }
.portal-empty-state strong { color: var(--ink); }

@media (max-width: 900px) {
    .portal-utility { top: max(12px, env(safe-area-inset-top)); right: 14px; }
    .portal-utility-button { min-height: 40px; padding: 8px 9px; }
    .portal-utility-button kbd { display: none; }
    .portal-install-button { display: none; }
    .portal-notification-panel { top: 64px; right: 14px; }
}

@media (max-width: 520px) {
    .portal-utility { right: 12px; gap: 5px; }
    .portal-utility-button { font-size: .72rem; padding: 8px; }
    .portal-command-palette { top: 8vh; padding: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (max-width: 768px) {
    .dashboard-app .compact-hero { gap: 12px; }

    .dashboard-app .tool-link:hover,
    .dashboard-app .tool-link:focus-visible { transform: none; }
}

/* Final shared UI pass: a calm, science-led BoldSage workspace. */
:root {
    --bs-cyan: #5dd6dc;
    --bs-gold: #d9ad4d;
    --bs-ink-deep: #07171d;
    --bs-ink-soft: #12343a;
    --bs-accent: #2f7771;
    --bs-accent-strong: #225d58;
    --bs-focus: rgba(47, 119, 113, .34);
    --bs-radius: 12px;
    --bs-radius-sm: 9px;
    --bs-shadow: 0 14px 38px rgba(7, 23, 29, .07);
    --bs-shadow-hover: 0 18px 44px rgba(7, 23, 29, .12);
}

html { background: var(--page); }

body {
    background: var(--page);
    color: var(--ink);
    font-size: 15px;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(93, 214, 220, .3); }

.app {
    grid-template-columns: minmax(258px, 286px) minmax(0, 1fr);
    background: var(--page);
}

.sidebar {
    position: relative;
    background: linear-gradient(164deg, #07171d 0%, #0b262d 58%, #12363a 100%);
    border-right: 1px solid rgba(93, 214, 220, .16);
    box-shadow: 14px 0 42px rgba(7, 23, 29, .11);
    padding: 22px 16px;
}

.sidebar::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--bs-cyan), var(--bs-gold), transparent);
    opacity: .78;
}

.brand { gap: 13px; margin: 2px 8px 26px; }

.brand img {
    width: 46px;
    height: 46px;
    border-radius: 11px;
    box-shadow: 0 0 0 1px rgba(93, 214, 220, .32), 0 10px 22px rgba(0, 0, 0, .24);
}

.brand strong { font-size: 1.02rem; letter-spacing: .01em; }
.brand span { color: #a7c7c7; font-size: .7rem; letter-spacing: .02em; }

.portal-clock {
    margin: -4px 0 20px;
    border-color: rgba(93, 214, 220, .20);
    border-radius: var(--bs-radius-sm);
    background: linear-gradient(135deg, rgba(93, 214, 220, .10), rgba(217, 173, 77, .08));
    box-shadow: inset 0 1px rgba(255, 255, 255, .05);
}

.nav-shell { gap: 4px; }
.nav-title { color: #86a9aa; margin-top: 20px; }

.nav-summary,
.nav-link {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: var(--bs-radius-sm);
    transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.nav-summary { padding: 10px 12px; }
.nav-link { padding: 10px 12px; }

.nav-summary:hover,
.nav-link:hover {
    border-color: rgba(93, 214, 220, .16);
    background: rgba(93, 214, 220, .09);
    color: #f7ffff;
}

.nav-summary.active,
.nav-link.active {
    border-color: rgba(93, 214, 220, .22);
    background: rgba(93, 214, 220, .15);
    color: #fff;
    box-shadow: inset 3px 0 var(--bs-cyan), 0 6px 16px rgba(0, 0, 0, .10);
}

.nav-link.active::before { background: var(--bs-gold); }

.main {
    min-width: 0;
    max-width: 1680px;
    padding: 30px clamp(20px, 3vw, 48px) 40px;
}

.topbar,
.panel,
.metric,
.quick-action,
.action-card,
.tools-panel,
.home-hero,
.daily-focus,
.focus-card,
.tool-link,
.calendar-day,
.calendar-agenda-item {
    border-color: color-mix(in srgb, var(--line) 82%, var(--bs-accent) 18%);
    border-radius: var(--bs-radius);
    box-shadow: var(--bs-shadow);
}

.topbar,
.panel,
.metric,
.quick-action,
.action-card,
.tools-panel,
.home-hero,
.daily-focus,
.focus-card { background: var(--surface); }

.topbar {
    min-height: 74px;
    margin-bottom: 24px;
    padding: 18px 24px;
}

.topbar h1,
.compact-welcome h1,
.panel h2,
.panel h3,
.tools-panel h2 {
    color: var(--ink);
    letter-spacing: -.015em;
}

.eyebrow { color: var(--bs-accent-strong); font-size: .7rem; letter-spacing: .12em; }
.panel-heading { margin-bottom: 18px; }
.panel-heading .muted { font-size: .84rem; }

.metric {
    position: relative;
    overflow: hidden;
    padding: 18px 19px;
}

.metric::after {
    background: linear-gradient(90deg, var(--bs-cyan), var(--bs-gold));
    opacity: .42;
}

.metric span,
.quick-action span,
.action-card span,
.tool-link span { color: var(--muted); font-size: .7rem; letter-spacing: .10em; }
.metric strong { color: var(--bs-accent-strong); font-size: 1.62rem; }

.btn {
    min-height: 42px;
    border-radius: var(--bs-radius-sm);
    background: var(--bs-accent);
    box-shadow: 0 8px 18px rgba(47, 119, 113, .16);
    font-size: .84rem;
    letter-spacing: .005em;
}

.btn:hover { background: var(--bs-accent-strong); box-shadow: var(--bs-shadow-hover); }
.btn.secondary { background: color-mix(in srgb, var(--surface-soft) 78%, var(--line) 22%); color: var(--ink); box-shadow: none; }
.btn.secondary:hover { background: color-mix(in srgb, var(--surface-soft) 62%, var(--line) 38%); }
.btn.success { background: #397c59; }
.btn.danger { background: #b24f4d; }

input,
select,
textarea {
    border-color: color-mix(in srgb, var(--line) 75%, var(--bs-accent) 25%);
    border-radius: var(--bs-radius-sm);
    background: var(--surface);
    color: var(--ink);
    transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

input:hover,
select:hover,
textarea:hover { border-color: color-mix(in srgb, var(--bs-accent) 58%, var(--line) 42%); }
input:focus,
select:focus,
textarea:focus { border-color: var(--bs-accent); box-shadow: 0 0 0 4px rgba(47, 119, 113, .11); outline: 0; }

table { font-size: .88rem; }
thead th { background: color-mix(in srgb, var(--surface-soft) 72%, var(--bs-cyan) 28%); }
td, th { border-bottom-color: var(--line); }
tbody tr { transition: background-color .16s ease; }
tbody tr:hover { background: color-mix(in srgb, var(--surface) 78%, var(--bs-cyan) 22%); }

.badge,
.soft-pill {
    border: 1px solid rgba(47, 119, 113, .16);
    background: color-mix(in srgb, var(--surface-soft) 78%, var(--bs-cyan) 22%);
    color: var(--bs-accent-strong);
}

.quick-action,
.action-card,
.tool-link { transition: border-color .18s ease, background-color .18s ease, box-shadow .18s ease, transform .18s ease; }

.quick-action:hover,
.action-card:hover,
.tool-link:hover,
.quick-action:focus-visible,
.action-card:focus-visible,
.tool-link:focus-visible {
    border-color: rgba(47, 119, 113, .44);
    background: color-mix(in srgb, var(--surface) 94%, var(--bs-cyan) 6%);
    box-shadow: var(--bs-shadow-hover);
    transform: translateY(-2px);
}

.dashboard-app .compact-hero {
    border-radius: 16px;
    border-color: rgba(47, 119, 113, .25);
    background: linear-gradient(112deg, var(--surface) 0%, color-mix(in srgb, var(--surface) 88%, var(--bs-cyan) 12%) 100%);
    box-shadow: 0 18px 42px rgba(7, 23, 29, .10);
}

.dashboard-app .compact-hero::after { opacity: .72; }
.dashboard-app .profile-orb { background: linear-gradient(145deg, var(--bs-ink-soft), var(--bs-accent)); }
.dashboard-app .compact-role strong { color: var(--bs-accent-strong); }
.dashboard-app .compact-directory { background: var(--surface); }
.dashboard-app .tool-link { background: var(--surface); }
.dashboard-app .tool-link::before { background: color-mix(in srgb, var(--surface-soft) 75%, var(--bs-cyan) 25%); color: var(--bs-accent-strong); }
.dashboard-app .tool-link span { color: var(--bs-accent-strong); }

.calendar-day.is-today,
.calendar-day.today { border-color: var(--bs-accent); box-shadow: 0 0 0 3px rgba(47, 119, 113, .10); }
.calendar-event { background: color-mix(in srgb, var(--surface-soft) 72%, var(--bs-cyan) 28%); color: var(--bs-accent-strong); }

.chat-status[data-presence-state="online"] { border-color: rgba(63, 125, 85, .35); background: #eef8f0; color: #2f6648; }
.chat-status[data-presence-state="offline"] { border-color: rgba(148, 163, 184, .34); background: #f1f5f9; color: #475569; }

.portal-utility-button,
.portal-panel-close,
.portal-notification-actions button {
    border-color: rgba(47, 119, 113, .20);
    border-radius: var(--bs-radius-sm);
    background: color-mix(in srgb, var(--surface) 91%, var(--bs-cyan) 9%);
    color: var(--bs-ink-soft);
    box-shadow: 0 6px 16px rgba(7, 23, 29, .06);
}

.portal-utility-button:hover,
.portal-utility-button:focus-visible,
.portal-panel-close:hover,
.portal-notification-actions button:hover { border-color: var(--bs-accent); background: var(--surface); }
.portal-command-palette,
.portal-notification-panel { border-color: rgba(47, 119, 113, .25); border-radius: 14px; box-shadow: 0 28px 80px rgba(7, 23, 29, .24); }

.sidebar-footer { gap: 10px; }
.theme-panel { border-color: rgba(93, 214, 220, .18); border-radius: var(--bs-radius-sm); }
.theme-panel-summary { border-radius: var(--bs-radius-sm); }
.sidebar-logout .btn { min-height: 44px; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible { outline: 3px solid var(--bs-focus-color, var(--bs-accent)); outline-offset: 2px; }

@media (max-width: 1100px) {
    .app { grid-template-columns: 260px minmax(0, 1fr); }
    .main { padding-inline: 24px; }
    .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .app { display: block; }
    .main { max-width: none; padding: 76px 18px 24px; }
    .topbar { min-height: auto; }
    .portal-utility { top: max(12px, env(safe-area-inset-top)); right: 14px; }
    .portal-utility-button { min-height: 40px; }
}

@media (max-width: 640px) {
    .main { padding: 72px 12px 18px; }
    .topbar, .panel, .metric, .quick-action, .action-card, .tools-panel { padding: 16px; border-radius: var(--bs-radius-sm); }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric strong { font-size: 1.28rem; }
    .topbar { gap: 12px; margin-bottom: 16px; }
    .portal-utility { right: 10px; gap: 5px; }
    .portal-utility-button { padding: 8px; font-size: .72rem; }
    .portal-install-button { display: none; }
    .quick-action:hover, .action-card:hover, .tool-link:hover { transform: none; }
}

@media (max-width: 420px) {
    .metrics { grid-template-columns: 1fr; }
    .portal-utility-button { min-width: 38px; }
}

/* Mobile shell correction: keep the drawer out of document flow and reserve its footer. */
@media (max-width: 900px) {
    .app {
        display: block;
        min-height: 100dvh;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1100;
        display: flex;
        flex-direction: column;
        width: min(84vw, 320px);
        height: 100dvh;
        min-height: 0;
        overflow: hidden;
        transform: translateX(-102%);
        transition: transform 220ms ease;
        overscroll-behavior: contain;
    }

    body.nav-open .sidebar { transform: translateX(0); }

    .main {
        display: block;
        width: 100%;
        max-width: none;
        position: relative;
        z-index: 1;
        min-height: 100dvh;
        margin: 0;
        overflow: visible;
        opacity: 1;
        visibility: visible;
    }

    .dashboard-app,
    .main.dashboard-compact {
        display: block;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        overflow: visible;
    }

    .dashboard-app .main { height: auto; }

    .sidebar > .brand,
    .sidebar > .portal-clock,
    .sidebar > .sidebar-footer { flex: 0 0 auto; }

    .sidebar > .nav-shell {
        flex: 1 1 auto;
        min-height: 0;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
    }

    .sidebar-footer {
        flex: 0 0 auto;
        max-height: min(34dvh, 260px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

@media (max-width: 560px) {
    .sidebar {
        width: min(90vw, 320px);
    }

    .sidebar-footer { max-height: min(32dvh, 230px); }
}

/* ---------------------------------------------------------------------------
   Notification centre — interaction fixes.

   `.portal-notification-center` is `isolation: isolate`, so its children form
   their own stacking context. The backdrop inherited z-index 1130 from the
   rule it shares with the command palette (where the backdrop IS a top-level
   sibling), while the panel sits at z-index 1. Inside the isolated context
   that put the translucent backdrop *on top of* the panel, dimming it and
   swallowing every click — the panel rendered but could not be used.

   Scope both children to the centre and order them locally. The command
   palette's own backdrop is untouched and still needs its 1130.
   --------------------------------------------------------------------------- */
.portal-notification-center .portal-notification-backdrop { z-index: 0; }
.portal-notification-center .portal-notification-panel { z-index: 1; }

/* `--surface-soft` is referenced but never defined anywhere in this file, so
   every color-mix() using it is invalid and dropped. Define it locally rather
   than globally so nothing outside the notification/command surfaces shifts. */
.portal-notification-center,
.portal-command-palette { --surface-soft: #f6f8fb; }

/* The whole card is a click target now, not just the "Open" link. */
.portal-notification-item {
    align-items: center;
    padding-left: 9px;
    border-left: 3px solid transparent;
    border-radius: 8px;
    cursor: pointer;
}
.portal-notification-item:hover,
.portal-notification-item:focus-visible {
    background: color-mix(in srgb, var(--surface-soft) 82%, var(--bs-cyan) 18%);
    outline: none;
}
.portal-notification-item:focus-visible { box-shadow: 0 0 0 2px var(--bs-accent); }
.portal-notification-link { pointer-events: none; }
