/* ==========================================================================
   CraftX ERP — Shell chrome (sidebar + topbar + page header)
   Global utility CSS. No per-component scoped styles.
   Source: design-pkg/craftx-design-system/project/erp/index.html
   Token-only: all values reference vars defined in app.css / tokens.css.
   ========================================================================== */

/* ── Shell container ───────────────────────────────────────────────────── */

.erp-shell {
    display: grid;
    grid-template-columns: var(--cx-sidebar-w) 1fr;
    /* --cx-app-h already subtracts the maintenance banner (0px when none).
       The downward shift comes from body padding-top (see app.css); here we
       only shrink the shell to keep the total at one viewport (no scrollbar). */
    grid-template-rows: var(--cx-app-h);
    height: var(--cx-app-h);
    max-width: 100vw;
    overflow: hidden;
    background: var(--cx-content-bg);
    transition: grid-template-columns 0.25s var(--ease);
}

@media (min-width: 769px) {
    .erp-shell.sidebar-collapsed {
        grid-template-columns: var(--cx-sidebar-w-collapsed) 1fr;
    }
}

.erp-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Containing block for the right-hand drawers below. Syncfusion adds it only through
       .e-sidebar-context once its JS has run; before that (prerender, circuit not up yet) the
       closed drawer, parked one drawer width to the right, widened the whole document. */
    position: relative;
    overflow: hidden;
    background: var(--cx-content-bg);
}

.erp-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    position: relative;
}

/* Right-hand drawers (ContactSidebar, JobSidebar via DynamicSidebar) mount into .erp-main —
   the non-scrolling shell column — and sit below the app bar. Mounting into .erp-content
   would make them scroll away with the page; mounting into body would cover the app bar. */
.erp-main > .e-sidebar.e-right {
    top: var(--cx-topbar-h);
    height: calc(100% - var(--cx-topbar-h));
}

/* Full-bleed pages opt out of the default content padding by adding
   `full-bleed` to their root element. Used for calendar, kanban,
   maps and any page that should run edge-to-edge below the topbar. */
.erp-content:has(> .full-bleed),
.erp-content.full-bleed {
    padding: 0;
}

/* Pages that fill the height left in the content column opt in with
   `cx-fill-height` on their root: the column lays them out as a flex
   column, so a banner above them (trial, mailbox) keeps its own height
   and the page takes the rest instead of 100 % plus the banner. */
.erp-content:has(> .cx-fill-height) {
    display: flex;
    flex-direction: column;
}

.erp-content > .cx-fill-height {
    flex: 1 0 auto;
}

/* Padded pages opt in to gutters around their root. Default `.erp-content`
   is flush so list/management pages can render their own `.cx-page-header`
   /`.cx-toolbar-section` flush to the topbar. Dashboards, summaries and
   any page that renders bare cards directly should wrap their content in
   `.cx-page-padded` to restore the framing gutter. */
.cx-page-padded {
    padding: 28px 40px 40px;
}
@media (max-width: 768px) {
    .cx-page-padded { padding: 16px; }
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */

.erp-sidebar {
    background: linear-gradient(180deg, var(--cx-sidebar-bg) 0%, var(--cx-sidebar-bg-2) 100%);
    color: var(--cx-sidebar-text);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 10;
}

.sidebar-header {
    height: var(--cx-topbar-h);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    border-bottom: 1px solid var(--cx-sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--cx-radius-control);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    color: white;
    transition: background 0.18s var(--ease);
}

.sidebar-header:hover .sidebar-logo {
    background: var(--copper);
}

.sidebar-logo svg {
    width: 18px;
    height: 18px;
}

.sidebar-brand {
    font-family: var(--font-display);
    font-weight: var(--fw-xbold);
    font-size: 17px;
    color: white;
    letter-spacing: -0.035em;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand .x {
    color: var(--copper-light);
}

.sidebar-brand > span {
    color: var(--cx-sidebar-text-muted);
    font-weight: var(--fw-medium);
    letter-spacing: -0.02em;
}

/* ── Sidebar nav ───────────────────────────────────────────────────────── */

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--cx-nav-pad);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--cx-radius-surface);
}

/* Density (o728): every measure of the list is a token (app.css, „Navigation: Dichte der Seitenleiste“), stepped by
   window height there. A group has no margin of its own: the air above its title is the whole distance. */
.nav-group-title {
    font-size: 10px;
    font-weight: var(--fw-semibold);
    line-height: var(--cx-nav-title-line);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--cx-sidebar-text-muted);
    padding: var(--cx-nav-title-pad-top) var(--cx-nav-row-pad-x) var(--cx-nav-title-pad-bottom);
    white-space: nowrap;
    overflow: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: var(--cx-nav-row-pad-y) var(--cx-nav-row-pad-x);
    border-radius: var(--cx-radius-control);
    color: var(--cx-sidebar-text);
    font-size: 13.5px;
    font-weight: var(--fw-medium);
    /* The row is its line box plus the padding. Inherited 1.5 made the 17 px icon a 25.5 px box: 41.5 px rows. */
    line-height: var(--cx-nav-row-line);
    cursor: pointer;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    margin-bottom: var(--cx-nav-row-gap);
    text-decoration: none;
}

.nav-item i {
    font-size: var(--cx-nav-icon-size);
    line-height: var(--cx-nav-row-line);
    width: var(--cx-nav-icon-box);
    text-align: center;
    flex-shrink: 0;
    color: inherit;
}

.nav-item span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-item:hover {
    background: var(--cx-sidebar-hover);
    color: var(--cx-sidebar-text-hover);
}

/* The filled shapes of the sidebar's icons (Phosphor, self-hosted: lib/phosphor/2.1.2/SOURCE.txt). Regular and fill
   share their code points, so the current entry only switches the font. */
@font-face {
    font-family: "Phosphor-Fill";
    src: url("../lib/phosphor/2.1.2/fill/Phosphor-Fill.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

/* The current entry shows the filled shape of its icon: the chosen place is plain to see, also collapsed and in
   the phone menu, on the gear of „Einstellungen“ and on the current page in its menu. !important answers the
   icon set's own (style.css). */
.nav-item.active i.ph,
.settings-menu .menu-item[aria-current="page"] i.ph {
    font-family: "Phosphor-Fill" !important;
}

/* The current place (design standard, rule 16): copper bar at the left edge, copper-tinted ground, label and icon
   in light copper, bold. Light copper on the tinted dark ground keeps 4.5:1 (rule 19). */
.nav-item.active {
    background: var(--cx-sidebar-active-bg);
    color: var(--cx-sidebar-active-fg);
    font-weight: var(--fw-semibold);
}

/* The bar stands at the sidebar's edge, in the list's padding; the row does not clip it. */
.sidebar-nav .nav-item {
    overflow: visible;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--cx-nav-pad));
    top: var(--cx-nav-row-pad-y);
    bottom: var(--cx-nav-row-pad-y);
    width: var(--cx-nav-active-bar);
    background: var(--copper);
    border-radius: 0 var(--cx-radius-control) var(--cx-radius-control) 0;
}

.nav-item.active i {
    color: var(--cx-sidebar-active-fg);
}

/* ── Nav badge ─────────────────────────────────────────────────────────── */

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: var(--cx-radius-round);
    background: var(--cx-primary);
    color: white;
    font-size: 10.5px;
    font-weight: var(--fw-bold);
    display: grid;
    place-items: center;
    letter-spacing: 0;
}

.nav-badge.muted {
    background: rgba(255, 255, 255, 0.12);
    color: var(--cx-sidebar-text-hover);
}

.nav-badge.urgent {
    background: var(--cx-danger);
    color: white;
}

/* The badge is a span too: without this, `.nav-item span { flex: 1 }` stretches the pill and cuts the label short. */
.nav-item .nav-badge {
    flex: none;
}

/* ── Sidebar footer ───────────────────────────────────────────────────── */

.sidebar-footer {
    border-top: 1px solid var(--cx-sidebar-border);
    padding: var(--cx-sidebar-footer-pad) var(--cx-sidebar-footer-pad-x);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Last row of the navigation: the profile (ProfileMenu, placement Sidebar), the gear of „Einstellungen“
   (SidebarSettingsMenu, only for those who may open one of its pages) and the collapse arrow. */
.sidebar-footer-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

.sidebar-profile {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    padding: 6px;
    border-radius: var(--cx-radius-control);
    border: 1px solid transparent;
    background: transparent;
    color: var(--cx-sidebar-text-hover);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s var(--ease);
}

.sidebar-profile:hover,
.sidebar-profile.open {
    background: var(--cx-sidebar-hover);
}

.sidebar-profile .profile-avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
}

/* The status dot sits on the avatar's lower right edge, ringed in the sidebar colour. */
.sidebar-profile .profile-status {
    left: 29px;
    bottom: 5px;
    border-color: var(--cx-sidebar-bg-2);
}

.sidebar-profile-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.sidebar-profile-name {
    font-size: 13.5px;
    font-weight: var(--fw-semibold);
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-firm {
    font-size: 11.5px;
    color: var(--cx-sidebar-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer-row .nav-item.sidebar-toggle,
.sidebar-footer-row .nav-item.sidebar-settings {
    width: var(--cx-sidebar-icon-btn-w);
    height: var(--cx-nav-row-h);
    padding: 0;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
}

/* The gear is the current place on the pages of its entries: tint and copper like a row of the list, without the
   bar, which belongs to the sidebar's left edge. While its menu is open it keeps the hover ground. */
.sidebar-footer-row .nav-item.sidebar-settings.active::before {
    display: none;
}

.nav-item.sidebar-settings.open:not(.active) {
    background: var(--cx-sidebar-hover);
    color: var(--cx-sidebar-text-hover);
}

/* The menu holds the focus while open so the keys reach it; the ring belongs to its entries, not to the box. */
.profile-menu:focus {
    outline: none;
}

/* The profile menu opens upwards from that row. Two classes, so the place wins over the menu's base rule
   (.profile-menu in AppBar.razor), which opens it below the top bar. A low window scrolls inside the menu. */
.profile-menu.profile-menu--sidebar {
    top: auto;
    right: auto;
    left: 10px;
    bottom: calc(var(--cx-sidebar-footer-row-h) + 2 * var(--cx-sidebar-footer-pad));
    width: 300px;
    max-width: calc(100vw - 20px);
    max-height: calc(var(--cx-app-h) - 76px);
    overflow-y: auto;
}

/* The menu of „Einstellungen“ is the same surface, narrower: a handful of pages. The page the user is on is marked. */
.profile-menu.profile-menu--sidebar.settings-menu {
    width: 240px;
}

.settings-menu .menu-item[aria-current="page"] {
    background: var(--cx-hover-bg);
    font-weight: var(--fw-semibold);
}

/* ── Collapsed state ──────────────────────────────────────────────────── */
/* Desktop only: up to 768 px the sidebar is the phone menu and always written out. */

@media (min-width: 769px) {
    .erp-shell.sidebar-collapsed .sidebar-brand,
    .erp-shell.sidebar-collapsed .nav-group-title,
    .erp-shell.sidebar-collapsed .nav-item span {
        display: none;
    }

    .erp-shell.sidebar-collapsed .sidebar-header {
        padding: 0;
        justify-content: center;
    }

    .erp-shell.sidebar-collapsed .nav-item {
        justify-content: center;
        padding: var(--cx-nav-row-pad-y) 0;
    }

    /* Group headings give way to a thin line between groups. */
    .erp-shell.sidebar-collapsed .nav-group {
        margin-bottom: var(--cx-nav-sep-gap);
    }

    .erp-shell.sidebar-collapsed .nav-group + .nav-group {
        border-top: 1px solid var(--cx-sidebar-border);
        padding-top: var(--cx-nav-sep-gap);
    }

    /* The counter becomes a dot at the icon's top right, ringed in the sidebar colour:
       copper = new, grey = running total, red = overdue. The number is in the name tag. */
    .erp-shell.sidebar-collapsed .nav-item .nav-badge {
        display: block;
        position: absolute;
        top: calc(var(--cx-nav-row-pad-y) - 3px);
        left: calc(50% + 5px);
        flex: none;
        width: 8px;
        min-width: 0;
        height: 8px;
        padding: 0;
        margin: 0;
        border-radius: var(--cx-radius-round);
        font-size: 0;
        box-shadow: 0 0 0 2px var(--cx-sidebar-bg);
    }

    .erp-shell.sidebar-collapsed .nav-item .nav-badge.muted {
        background: var(--cx-sidebar-text-muted);
    }

    /* The toggle's arrow points left; collapsed, it points right. */
    .erp-shell.sidebar-collapsed .sidebar-toggle i {
        transform: scaleX(-1);
    }

    /* Collapsed, the profile is only the avatar, with the gear and the arrow below it; the menus open beside the sidebar. */
    .erp-shell.sidebar-collapsed .sidebar-footer-row {
        flex-direction: column;
        gap: 4px;
    }

    .erp-shell.sidebar-collapsed .sidebar-profile {
        flex: none;
        padding: 5px;
        justify-content: center;
    }

    .erp-shell.sidebar-collapsed .sidebar-profile-text {
        display: none;
    }

    .erp-shell.sidebar-collapsed .sidebar-profile .profile-status {
        left: 28px;
        bottom: 4px;
    }

    .erp-shell.sidebar-collapsed .sidebar-footer-row .nav-item.sidebar-toggle,
    .erp-shell.sidebar-collapsed .sidebar-footer-row .nav-item.sidebar-settings {
        width: 100%;
    }

    .erp-shell.sidebar-collapsed .profile-menu.profile-menu--sidebar {
        left: 72px;
        bottom: 10px;
        max-height: calc(var(--cx-app-h) - 20px);
    }
}

/* Name tag beside a collapsed sidebar's icon (site.js: showSidebarNameTag). Fixed on <body>, because the sidebar
   clips its overflow. */
.cx-nav-tag {
    position: fixed;
    z-index: 1400;
    transform: translateY(-50%);
    padding: 6px 12px;
    border-radius: var(--cx-radius-control);
    background: var(--ink);
    color: white;
    font-size: 12.5px;
    font-weight: var(--fw-semibold);
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
}

.cx-nav-tag[hidden] {
    display: none;
}

.cx-nav-tag__hint {
    color: var(--cx-sidebar-text);
    font-weight: var(--fw-medium);
}

/* ── Topbar ───────────────────────────────────────────────────────────── */

.erp-topbar {
    height: var(--cx-topbar-h);
    background: rgba(250, 247, 242, 0.82);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--cx-hairline);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    /* Must beat legacy in-page wrappers like .job-header-wrapper (1050) so
       topbar dropdowns (Schnell-erstellen, notifications, profile) render
       above page content. backdrop-filter also creates a stacking context,
       which clips absolute children to the topbar's z-index. */
    z-index: 1100;
}

/* After the bar's own rule: on the review page of a document the bar stays mounted and is only not drawn. */
.erp-main.hides-appbar > .erp-topbar {
    display: none;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Search and quick-add start at the left edge of the bar, in line with the page content below; the icons stand at
   its right end. When the bar gets narrow the search gives way, the icons keep their size. */

/* Phones and the menu-button bar: fingers, not a mouse — the controls keep 36 px. */
@media (max-width: 768px) {
    :root {
        --cx-topbar-control-h: 36px;
    }
}

/* No padding: the grid centres the icon in the button. Chat and bell also carry the old .chat-button /
   .notification-button rules (AppBar.razor, padding 8px), which pinned their icon 8 px below the top edge. */
.erp-topbar .icon-button {
    width: var(--cx-topbar-control-h);
    height: var(--cx-topbar-control-h);
    padding: 0;
}

/* The badges (chat count, bell number, quiet dot) were placed from the corner of a 36 px button whose icon sat 8 px
   below the top edge. Centred, that icon moves up by 3 px in a 36 px button and comes closer to the corner by half of
   any smaller size; the badges move along so they keep their place on the icon (measured, symbole.js). */
.erp-topbar .icon-button .badge-dot {
    translate: calc((36px - var(--cx-topbar-control-h)) / 2) calc((var(--cx-topbar-control-h) - 36px) / 2 - 3px);
}

/* ── Icon button (topbar actions) ─────────────────────────────────────── */

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: var(--cx-radius-control);
    border: none;
    background: transparent;
    color: var(--cx-text-secondary);
    display: grid;
    place-items: center;
    font-size: 16px;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    font-family: inherit;
}

/* Opens the sidebar as a menu; only on phones (see the responsive block at the end). */
.erp-topbar .topbar-menu-btn {
    display: none;
}

.icon-button:hover {
    background: rgba(28, 25, 21, 0.05);
    color: var(--cx-text-primary);
}

.icon-button .badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: var(--cx-radius-round);
    background: var(--cx-danger);
    color: white;
    font-size: 9.5px;
    font-weight: var(--fw-bold);
    display: grid;
    place-items: center;
    border: 2px solid rgba(255, 255, 255, 0.85);
}

/* ── Topbar search ─────────────────────────────────────────────────────── */

.topbar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: var(--cx-topbar-search-w);
    flex: 1;
    min-width: 0; /* gives way to the buttons beside it instead of pushing them over each other */
    height: var(--cx-topbar-control-h);
    padding: 0 14px;
    background: rgba(28, 25, 21, 0.04);
    border: 1px solid transparent;
    border-radius: var(--cx-radius-control);
    transition: all 0.15s var(--ease);
}

/* The search is a button since the command palette (o645): it opens the dialog, it takes no text itself. */
button.topbar-search {
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--cx-text-primary);
}

/* Hover turns the surface white with a fine border — „this can be clicked“, without copper. */
.topbar-search:hover {
    background: white;
    border-color: rgba(28, 25, 21, 0.30);
}

.topbar-search:focus-visible {
    outline: none;
    background: white;
    border-color: var(--cx-primary);
    box-shadow: 0 0 0 3px rgba(184, 96, 31, 0.15);
}

.topbar-search i {
    color: var(--cx-text-muted);
    font-size: 15px;
}

.topbar-search .label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--cx-placeholder-color);
}

.topbar-search .label.has-query {
    color: var(--cx-text-primary);
}

.topbar-search .kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 6px;
    background: rgba(28, 25, 21, 0.06);
    border-radius: var(--cx-radius-control);
    color: var(--cx-text-secondary);
    white-space: nowrap;
}

/* ── Quick-add CTA ─────────────────────────────────────────────────────── */
/* Outline variant — topbar is a global utility surface, so the quick-add
   shouldn't compete with the page-level primary CTA (.cx-header-btn).
   Copper border + text reads as branded but doesn't dominate. */

.quick-add-btn {
    height: var(--cx-topbar-control-h);
    padding: 0 12px 0 10px;
    border-radius: var(--cx-radius-control);
    background: transparent;
    color: var(--copper-dark);
    border: 1px solid var(--copper);
    font-size: 13px;
    font-weight: var(--fw-semibold);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
    font-family: inherit;
    cursor: pointer;
}

.quick-add-btn:hover {
    background: var(--copper-50);
    border-color: var(--copper-dark);
    color: var(--copper-dark);
}

.quick-add-btn i {
    font-size: 15px;
}

/* ── Profile chip ──────────────────────────────────────────────────────── */

.profile-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--cx-radius-control);
    background: transparent;
    border: 1px solid var(--cx-hairline);
    transition: background 0.15s var(--ease);
    margin-left: 6px;
    position: relative;
    cursor: pointer;
    font-family: inherit;
}

.profile-chip:hover {
    background: rgba(28, 25, 21, 0.04);
}

.profile-avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--cx-radius-round);
    background: var(--cx-info);
    color: white;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: var(--fw-bold);
    flex-shrink: 0;
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-name {
    font-size: 13px;
    font-weight: var(--fw-semibold);
    color: var(--cx-text-primary);
    white-space: nowrap;
}

.profile-status {
    width: 9px;
    height: 9px;
    border-radius: var(--cx-radius-round);
    background: var(--cx-success);
    border: 2px solid white;
    position: absolute;
    bottom: 3px;
    left: 23px;
}

.profile-status.online { background: var(--cx-success); }
.profile-status.away { background: var(--cx-warning); }
.profile-status.do-not-disturb { background: var(--cx-danger); }
.profile-status.offline { background: var(--cx-text-muted); }

/* Phones: search, quick-add and the right-hand icons share 390 px. The quick-add
   keeps only its icon (the label stays as accessible name), the profile chip only
   the avatar; the ⌘K hint has no keyboard to go with it. */
@media (max-width: 639.98px) {
    .erp-topbar { padding: 0 12px; gap: 8px; }
    .topbar-left { gap: 8px; }
    .topbar-right { gap: 0; }
    .topbar-search { padding: 0 10px; gap: 8px; }
    .topbar-search .kbd { display: none; }
    .quick-add-btn { width: var(--cx-topbar-control-h); padding: 0; justify-content: center; }
    .quick-add-btn span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
    .profile-chip { padding: 3px; margin-left: 4px; }
    .profile-chip .profile-name { display: none; }
}

/* ── Page header (inside erp-content) ─────────────────────────────────── */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 24px;
    flex-wrap: wrap;
}

.page-title {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: var(--fw-bold);
    letter-spacing: -0.02em;
    color: var(--cx-text-primary);
    margin: 0 0 4px;
    line-height: 1.15;
}

.page-subtitle {
    font-size: 14px;
    color: var(--cx-text-muted);
    margin: 0;
}

.wave {
    display: inline-block;
    animation: wave 2.5s ease-in-out infinite;
    transform-origin: 70% 70%;
}

@keyframes wave {
    0%, 60%, 100% { transform: rotate(0); }
    10%, 30% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    40%, 50% { transform: rotate(10deg); }
}

/* ── Loading / error states (inside erp-content or full-screen) ───────── */

.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--cx-sidebar-bg);
    z-index: 2000;
    color: white;
}

.loading-container p {
    margin-top: 1rem;
    font-size: 1.1rem;
}

.content-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(250, 247, 242, 0.8);
    z-index: 1000;
}

.error-container {
    text-align: center;
    padding: 3rem 1rem;
    background-color: var(--cx-card-bg);
    border-radius: var(--cx-radius-surface);
    margin: 2rem auto;
    max-width: 600px;
    box-shadow: var(--shadow-sm);
}

.error-container .error-icon {
    font-size: 2.5rem;
    color: var(--cx-danger);
    margin-bottom: 1rem;
}

.error-container h3 {
    margin-bottom: 0.75rem;
    color: var(--cx-text-primary);
    font-weight: var(--fw-semibold);
}

.error-container p {
    color: var(--cx-text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.error-container .retry-button {
    padding: 0.5rem 1rem;
    background-color: var(--cx-primary);
    color: white;
    border: none;
    border-radius: var(--cx-radius-control);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-family: inherit;
}

.error-container .retry-button:hover {
    background-color: var(--cx-primary-hover);
}

.error-container .retry-button i {
    font-size: 1rem;
}

/* ── Public (unauthenticated) full-bleed content ───────────────────────── */

.erp-public-content {
    min-height: var(--cx-app-h);
    width: 100%;
    background: var(--cx-content-bg);
}

/* ── Global error banner (bottom of viewport) ─────────────────────────── */

#blazor-error-ui {
    background: #7f1d1d;
    color: #fef2f2;
    padding: 1rem;
    border-radius: var(--cx-radius-surface);
    box-shadow: var(--shadow-md);
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    right: 1rem;
    z-index: 2000;
    display: none;
    align-items: center;
    gap: 1rem;
}

#blazor-error-ui[style*="block"] {
    display: flex !important;
}

#blazor-error-ui a {
    color: #fecaca;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    margin-left: auto;
    font-size: 1.5rem;
    line-height: 1;
}

/* ── Responsive: mobile off-canvas sidebar ────────────────────────────── */

@media (max-width: 768px) {
    .erp-shell {
        grid-template-columns: 1fr;
    }

    .erp-shell.sidebar-collapsed {
        grid-template-columns: 1fr;
    }

    .erp-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--cx-sidebar-w);
        transform: translateX(-100%);
        transition: transform 0.3s var(--ease);
        z-index: 1300;
    }

    .erp-sidebar.mobile-visible {
        transform: translateX(0);
    }

    .erp-content {
        padding: 16px 20px 24px;
    }

    body.mobile-sidebar-open::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1250;
    }

    /* The phone menu is always written out; collapsing has no meaning here. */
    .erp-sidebar .sidebar-toggle {
        display: none;
    }

    .erp-topbar .topbar-menu-btn {
        display: grid;
        font-size: 20px;
        color: var(--cx-text-primary);
    }

    /* The follow-up sidebar is no .erp-sidebar: there is no menu to open. */
    .erp-shell:not(:has(.erp-sidebar)) .topbar-menu-btn {
        display: none;
    }
}

/* Tablets and other touch devices without a keyboard or mouse: the ⌘K hint has no key to go with it.
   An iPad with a trackpad or mouse reports a fine pointer and keeps the hint. */
@media (hover: none) and (pointer: coarse) {
    .topbar-search .kbd { display: none; }
}
