/* ==========================================================================
   App top bar — the "context bar" (6 Oct 2026)
   --------------------------------------------------------------------------
   Left:   menu · business switcher (logo, name, and a line with the branch
           and plan: App._updateTopbarContext in shell-nav.js)
   Middle: a search box on wide screens (Ctrl/Cmd + K opens it too), an icon
           on phones
   Right:  "+ New" · flag and bell in one soft group · you (photo, name, role)

   Scoped to #main-app's top bar and linked after every other sheet, so the
   older .topbar rules in app.css are overridden here rather than edited.
   True-black primary text; greys no lighter than #475569.
   ========================================================================== */

#main-app > header.topbar {
    --tb-line: #e6eaf0;
    --tb-soft: #f4f6f9;
    display: flex; align-items: center; gap: 12px;
    padding-left: 16px; padding-right: 16px;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid var(--tb-line);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02), 0 6px 18px -16px rgba(15, 23, 42, .35);
}
#main-app > header.topbar .topbar-left,
#main-app > header.topbar .topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
#main-app > header.topbar .topbar-center {
    flex: 1 1 auto; min-width: 0;
    display: flex; justify-content: center;
}

/* Menu button: same size as everything else in the row */
#main-app > header.topbar .menu-toggle {
    width: 40px; height: 40px; border-radius: 12px;
    background: #fff; border: 1px solid var(--tb-line);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
#main-app > header.topbar .menu-toggle:hover { border-color: #cbd5e1; background: #fff; }

/* ---- Business switcher ---------------------------------------------------- */
#main-app > header.topbar .biz-picker-btn {
    height: 44px; max-width: 260px; gap: 10px;
    padding: 4px 12px 4px 4px; border-radius: 13px;
    background: #fff; border: 1px solid var(--tb-line);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
#main-app > header.topbar .biz-picker-btn:hover { border-color: #cbd5e1; background: #fff; box-shadow: 0 2px 8px -4px rgba(15, 23, 42, .2); }
#main-app > header.topbar .biz-avatar-xs {
    width: 34px; height: 34px; border-radius: 10px; font-size: .8rem;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .06);
}
#main-app > header.topbar .biz-picker-text {
    display: flex; flex-direction: column; justify-content: center;
    min-width: 0; flex: 1 1 auto; text-align: left; line-height: 1.15;
}
#main-app > header.topbar .biz-picker-name {
    max-width: 180px; font-size: .86rem; font-weight: 800; color: #000;
}
#main-app > header.topbar .biz-picker-sub {
    max-width: 180px; margin-top: 2px;
    font-size: .68rem; font-weight: 650; color: #475569;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#main-app > header.topbar .biz-picker-sub:empty { display: none; }

/* ---- Search --------------------------------------------------------------- */
#main-app > header.topbar .topbar-search {
    display: flex; align-items: center; gap: 10px;
    width: 100%; max-width: 520px; height: 42px;
    padding: 0 8px 0 14px; border-radius: 13px;
    background: var(--tb-soft); border: 1px solid var(--tb-line);
    color: #334155; font: inherit; cursor: pointer; text-align: left;
    transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}
#main-app > header.topbar .topbar-search:hover { background: #fff; border-color: #cbd5e1; box-shadow: 0 2px 10px -6px rgba(15, 23, 42, .25); }
#main-app > header.topbar .topbar-search:focus-visible { outline: 3px solid var(--accent-ring, rgba(16, 185, 129, .35)); outline-offset: 2px; }
#main-app > header.topbar .topbar-search > i { font-size: .98rem; color: #475569; }
#main-app > header.topbar .tb-search-ph {
    flex: 1 1 auto; min-width: 0;
    font-size: .84rem; font-weight: 600; color: #475569;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#main-app > header.topbar .tb-kbd {
    flex: none; padding: 3px 7px; border-radius: 7px;
    background: #fff; border: 1px solid var(--tb-line); box-shadow: 0 1px 0 var(--tb-line);
    font: inherit; font-size: .68rem; font-weight: 750; color: #334155; letter-spacing: .02em;
}

/* ---- Right-hand group ----------------------------------------------------- */
#main-app > header.topbar .topbar-quick-add {
    width: auto; height: 40px; padding: 0 14px 0 12px; gap: 6px; border-radius: 12px;
    font-size: .84rem; font-weight: 800;
}
#main-app > header.topbar .topbar-quick-add i { font-size: 1rem; }

/* Flag and notifications share one soft capsule */
#main-app > header.topbar .tb-cluster {
    display: flex; align-items: center; gap: 2px;
    height: 42px; padding: 3px; border-radius: 13px;
    background: var(--tb-soft); border: 1px solid var(--tb-line);
}
#main-app > header.topbar .tb-cluster .topbar-flag {
    width: 34px; height: 34px; border-radius: 10px;
    background: transparent; border: 0;
}
#main-app > header.topbar .tb-cluster .topbar-icon {
    width: 34px; height: 34px; border-radius: 10px;
    background: transparent; border: 0; box-shadow: none; color: #1e293b;
}
#main-app > header.topbar .tb-cluster .topbar-icon:hover { background: #fff; color: #000; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

/* You */
#main-app > header.topbar .tb-me {
    display: flex; align-items: center; gap: 9px;
    height: 44px; padding: 3px 10px 3px 3px; border-radius: 999px;
    background: #fff; border: 1px solid var(--tb-line);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    font: inherit; color: #000; cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}
#main-app > header.topbar .tb-me:hover { border-color: #cbd5e1; box-shadow: 0 2px 8px -4px rgba(15, 23, 42, .2); }
#main-app > header.topbar .tb-me .avatar-sm {
    width: 36px; height: 36px; flex: 0 0 36px; border: 0;
    box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--tb-line);
}
#main-app > header.topbar .tb-me-text { display: flex; flex-direction: column; min-width: 0; text-align: left; line-height: 1.15; }
#main-app > header.topbar .tb-me-name {
    max-width: 130px; font-size: .82rem; font-weight: 800; color: #000;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#main-app > header.topbar .tb-me-role { margin-top: 2px; font-size: .66rem; font-weight: 700; color: #475569; }
#main-app > header.topbar .tb-me-name:empty,
#main-app > header.topbar .tb-me-role:empty { display: none; }
#main-app > header.topbar .tb-me-caret { font-size: .66rem; color: #334155; }

/* ---- Narrower screens ----------------------------------------------------- */
@media (max-width: 1180px) {
    #main-app > header.topbar .tb-me-text,
    #main-app > header.topbar .tb-me-caret { display: none; }
    #main-app > header.topbar .tb-me { padding: 3px; }
}
@media (max-width: 980px) {
    #main-app > header.topbar .tb-kbd { display: none; }
    #main-app > header.topbar .tb-new-label { display: none; }
    #main-app > header.topbar .topbar-quick-add { width: 40px; padding: 0; }
}
/* Tablets and phones: search shrinks to an icon beside the other buttons. */
@media (max-width: 767px) {
    #main-app > header.topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
    #main-app > header.topbar .topbar-center { justify-content: flex-end; }
    #main-app > header.topbar .topbar-search {
        width: 40px; max-width: 40px; height: 40px; padding: 0; justify-content: center;
        background: #fff; border-radius: 12px;
    }
    #main-app > header.topbar .tb-search-ph { display: none; }
    #main-app > header.topbar .topbar-right { gap: 6px; }
    #main-app > header.topbar .tb-cluster { height: 40px; padding: 2px; }
    #main-app > header.topbar .tb-cluster .topbar-flag,
    #main-app > header.topbar .tb-cluster .topbar-icon { width: 34px; height: 34px; }
    #main-app > header.topbar .tb-me { height: 40px; }
    #main-app > header.topbar .tb-me .avatar-sm { width: 32px; height: 32px; flex-basis: 32px; }
    #main-app > header.topbar .biz-picker-btn { height: 40px; max-width: 200px; }
    #main-app > header.topbar .biz-avatar-xs { width: 30px; height: 30px; border-radius: 9px; }
    #main-app > header.topbar .biz-picker-name,
    #main-app > header.topbar .biz-picker-sub { max-width: 120px; }
}
/* Phones: the switcher is its logo and chevron (dropdowns.css keeps the
   chevron visible), and the flag gives way to keep one tidy row. */
@media (max-width: 520px) {
    #main-app > header.topbar .biz-picker-btn { max-width: 66px; padding: 4px 8px 4px 4px; gap: 4px; }
    #main-app > header.topbar .biz-picker-text { display: none; }
}
@media (max-width: 400px) {
    #main-app > header.topbar .tb-cluster .topbar-flag { display: none !important; }
    #main-app > header.topbar .tb-cluster { padding: 2px; background: #fff; }
}
