/* ZenflowCRM platform admin.
   One stylesheet, design tokens on :root, and a dark palette that follows the viewer's setting
   unless a theme is stamped on <html>. */

:root {
    color-scheme: light;

    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --border: #e3e6ea;
    --border-strong: #cdd3da;

    --ink: #12161c;
    --ink-2: #4a5462;
    --ink-3: #78828f;

    --brand: #246DFF;
    --brand-ink: #ffffff;
    --brand-soft: #eef4ff;

    /* The two brand colours, the same pair the sign-in screen uses (auth.css), so the header,
       the wordmark and the login page read as one product. Blue on the left of the bar,
       cyan on the right, the way ZenflowHR draws it. */
    --brand-blue: #246DFF;
    --brand-cyan: #07C3D6;

    /* The top bar's gradient, and the one colour guaranteed to read on top of it. Text on the
       bar uses --on-brand; the ink tokens are for the page behind it and wash out there. */
    --brand-gradient: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-cyan) 100%);
    --on-brand: #ffffff;

    /* The wordmark, in the two colours the logo artwork itself is painted in — the same pair
       ZenflowHR uses. Not --brand-blue: that is the header blue and reads brighter than the
       symbol sitting beside the letters. */
    --logo-ink-1: #1870D1;
    --logo-ink-2: #07C3D6;

    --ok: #0f7b4f;
    --ok-soft: #e7f6ee;
    --warn: #9a5b00;
    --warn-soft: #fdf3e2;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --info: #0b63ce;
    --info-soft: #e8f1fd;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgb(16 22 28 / 6%), 0 4px 12px rgb(16 22 28 / 4%);
    /* The lift under the content panel and the navigation — ZenflowHR's --zf-card-shadow. */
    --shadow-panel: 0 4px 12px rgba(0, 0, 0, 0.08);

    --sidebar-width: 273px;
    --topbar-height: 65px;

    /* Inter, the same face ZenflowHR and the CRM sign-in screen use. The system stack stays
       behind it so a machine with no network still gets a sane face rather than Times. */
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg: #0d1117;
        --surface: #151b23;
        --surface-2: #1b222b;
        --border: #2a323d;
        --border-strong: #3a4552;

        --ink: #e9eef5;
        --ink-2: #a9b4c2;
        --ink-3: #7c8794;

        --brand: #58A6FF;
        --brand-ink: #0d1117;
        --brand-soft: #17233d;

        /* ZenflowHR lightens its primary in dark mode but keeps the header gradient exactly as
           it is in light, so the bar is written out in full here rather than following the
           lightened --brand-blue. */
        --brand-blue: #58A6FF;
        --brand-cyan: #07C3D6;
        --brand-gradient: linear-gradient(135deg, #246DFF 0%, #07C3D6 100%);
        --on-brand: #ffffff;

        --logo-ink-1: #4B9AF0;
        --logo-ink-2: #07C3D6;

        --ok: #4ade80;
        --ok-soft: #10261b;
        --warn: #fbbf24;
        --warn-soft: #2a2011;
        --danger: #f87171;
        --danger-soft: #2b1514;
        --info: #7aa7f0;
        --info-soft: #14203a;

        --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 14px rgb(0 0 0 / 30%);
        --shadow-panel: 0 1px 3px rgba(0, 0, 0, 0.3);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d1117;
    --surface: #151b23;
    --surface-2: #1b222b;
    --border: #2a323d;
    --border-strong: #3a4552;

    --ink: #e9eef5;
    --ink-2: #a9b4c2;
    --ink-3: #7c8794;

    --brand: #58A6FF;
    --brand-ink: #0d1117;
    --brand-soft: #17233d;

    --brand-blue: #58A6FF;
    --brand-cyan: #07C3D6;
    --brand-gradient: linear-gradient(135deg, #246DFF 0%, #07C3D6 100%);
    --on-brand: #ffffff;

    --logo-ink-1: #4B9AF0;
    --logo-ink-2: #07C3D6;

    --ok: #4ade80;
    --ok-soft: #10261b;
    --warn: #fbbf24;
    --warn-soft: #2a2011;
    --danger: #f87171;
    --danger-soft: #2b1514;
    --info: #7aa7f0;
    --info-soft: #14203a;
    --shadow-panel: 0 1px 3px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-3); font-size: 13px; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--brand);
    color: var(--brand-ink);
    padding: 10px 16px;
    z-index: 100;
}
.skip-link:focus { left: 8px; top: 8px; }

/* --- Shell ------------------------------------------------------------------------------ */

.shell {
    display: flex;
    min-height: 100vh;
    position: relative;
    background: var(--bg);
}

/* ZenflowHR's navigation is two boxes, and it matters which one carries what: an outer column
   holding the blue-to-page gradient, exactly one screen tall and stuck to the top, and a white
   panel inside it. The gradient is therefore bounded by the screen — below it there is only the
   page — which is why ZenflowHR shows no band down a long page. Putting the gradient on the shell
   instead stretched it over the whole document, and the part the panel did not cover read as a
   blue wash beside the content. */
.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    z-index: 30;
    position: sticky;
    top: 0;
    height: 100vh;
    background: linear-gradient(180deg, var(--brand-blue) 0%, var(--bg) 100%);
    transition: width 220ms ease, flex-basis 220ms ease;
}

/* The white panel — ZenflowHR's .left-menu. It fills its column, so the gradient behind it only
   ever shows through the rounded corner. */
.sidebar-inner {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    border-radius: 0 22px 22px 0;
    padding: env(safe-area-inset-top, 0px) 13px 0;
    transition: padding 220ms ease;
}

/* The button that narrows the navigation rides its right edge, so the sidebar must not clip
   its own overflow — the menu below does the scrolling instead. */
.sidebar-collapse {
    position: absolute;
    top: 16px;
    right: -17px;
    z-index: 25;
    width: 35px;
    height: 35px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: var(--brand-cyan);
    cursor: pointer;
}

.sidebar-collapse .line {
    display: block;
    width: 17px;
    height: 2px;
    border-radius: 10px;
    background: #ffffff;
    transition: transform 200ms ease;
}
.sidebar-collapse .line:nth-child(1) { width: 10px; transform: translateX(-3px); }
.sidebar-collapse .line:nth-child(3) { width: 10px; transform: translateX(3px); }
.sidebar-collapse:hover .line { transform: none; }

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 15px 5px;
}

.sidebar-logo__symbol { width: 36px; height: 36px; flex-shrink: 0; }

/* Same lockup as the sign-in screen: 900 weight at 12.5px, the two words almost flush.
   Anything looser stops reading as the logo and starts reading as two words. */
.sidebar-logo__word {
    font-size: 13.3px;
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;
    color: var(--logo-ink-1);
}
.sidebar-logo__word span { margin-left: 5px; color: var(--logo-ink-2); }

.sidebar-context {
    margin: 10px 5px;
    padding: 5px 10px;
    border-radius: 20px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    border-top: 1px solid var(--border);
    padding: 16px 0;
    /* ZenflowHR hides the track: a scrollbar down the middle of a 288px panel reads as a seam. */
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar-menu::-webkit-scrollbar { width: 0; }

.sidebar-menu ul { list-style: none; margin: 0; padding: 0; }
.menu-list { padding: 0 4px; }

/* A section header and a top-level link are the same row: 9px all round, a 10px gap after the
   glyph, 13px type. The weight is what separates them — 600 for a header, 400 for a link. */
.menu-group__toggle,
.menu-single > .menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    text-transform: capitalize;
    text-align: left;
    text-decoration: none;
}

/* ZenflowHR's rhythm, kept to the pixel: 15px of air above every section header and 2px below
   it, so the gap between two entries — Platform Overview to Customers, say — is the same height
   in both products. Adjacent margins collapse, so 15 wins over the 2 above it. The first entry
   drops the lead or the navigation opens on a hole. */
.menu-group__toggle { margin: 15px 0 2px; font-weight: 600; cursor: pointer; }
.menu-single > .menu-link { margin: 15px 0 2px; font-weight: 400; }
.menu-list > li:first-child > .menu-group__toggle,
.menu-list > li:first-child > .menu-link { margin-top: 0; }

.menu-group__toggle:hover,
a.menu-link:hover { background: var(--brand-soft); color: var(--ink); text-decoration: none; }
.menu-group.is-current > .menu-group__toggle { background: var(--brand-soft); }
a.menu-link.is-active { background: var(--brand-soft); color: var(--ink); font-weight: 500; }
.menu-link.is-planned { color: var(--ink-3); cursor: default; }

/* Sized to match the link glyphs below, so a header icon and a child icon share one vertical
   line down the sidebar. */
.menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    font-size: 15px;
}
.menu-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu-chevron {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 12px;
    color: var(--ink-3);
    transition: transform 200ms ease;
}
.menu-group.is-open > .menu-group__toggle .menu-chevron { transform: rotate(180deg); }

/* Rows animate open on grid-template-rows, so the group can grow to whatever height its
   children need without a hardcoded max-height that cuts a long section off. */
.menu-collapse {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 220ms ease;
}
.menu-group.is-open > .menu-collapse { grid-template-rows: 1fr; }

/* The guide rail. A section's screens hang off one hairline instead of floating on a flat
   indent, which is how ZenflowHR shows where a section starts and stops. */
.sidebar-menu .submenu {
    overflow: hidden;   /* required by the 0fr/1fr trick above */
    min-height: 0;
    margin: 0 0 0 9px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px;
    border-radius: 8px;
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 400;
    text-transform: capitalize;
}

a.nav-link:hover { background: var(--brand-soft); color: var(--ink); text-decoration: none; }

/* The pill marks the open screen; the words keep their ink. Recolouring them as well made the
   row shout next to ZenflowHR's, where only the background changes. */
a.nav-link.is-active {
    background: var(--brand-soft);
    color: var(--ink);
    font-weight: 500;
}

.nav-link.is-planned { color: var(--ink-3); cursor: default; }

/* A group inside a section (Website › CMS) sits in the rail like a screen row, not like a
   section header: no 15px lead, regular weight, the screen rows' ink. */
.menu-group--nested > .menu-group__toggle {
    margin: 0;
    font-weight: 400;
    color: var(--ink-2);
}
.menu-group--nested.is-current > .menu-group__toggle { color: var(--ink); font-weight: 500; }

/* Narrowed sidebar: icons only. Desktop only — below 860px the sidebar is a drawer, where
   "narrowed" would mean an icon strip nobody asked for. */
@media (min-width: 861px) {
    :root.sidebar-collapsed .sidebar {
        width: 64px;
        flex-basis: 64px;
    }

    /* The padding lives on the white panel, not the column that holds it. */
    :root.sidebar-collapsed .sidebar-inner {
        padding-left: 8px;
        padding-right: 8px;
    }


    :root.sidebar-collapsed .sidebar-logo { justify-content: center; padding: 16px 0; }
    :root.sidebar-collapsed .sidebar-logo__word,
    :root.sidebar-collapsed .sidebar-context,
    :root.sidebar-collapsed .menu-text,
    :root.sidebar-collapsed .menu-chevron,
    :root.sidebar-collapsed .chip { display: none; }

    :root.sidebar-collapsed .menu-collapse { display: none; }

    /* In the rail a row is one centred glyph, so the 15px lead that separated section names
       would only push the icons apart. ZenflowHR evens them out at 4px. */
    :root.sidebar-collapsed .menu-group__toggle,
    :root.sidebar-collapsed .menu-single > .menu-link {
        justify-content: center;
        padding: 9px 5px;
        margin-top: 4px;
        margin-bottom: 4px;
    }
}

.chip {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.chip-planned { color: var(--ink-3); }
.chip-wip { color: var(--warn); background: var(--warn-soft); border-color: transparent; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

/* --- Top header ---------------------------------------------------------------------------
   The brand gradient bar, the same shape as ZenflowHR's: date on the left, screen search in the
   middle, theme toggle and account menu on the right. Everything sitting on the gradient takes
   its colour from --on-brand, never from the ink tokens, which are tuned for the page behind it. */

.top-header {
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 16px 11px 30px;
    padding-top: calc(11px + env(safe-area-inset-top, 0px));
    background: var(--brand-gradient);
    color: var(--on-brand);
    position: sticky;
    top: 0;
    z-index: 20;
}

.top-header__left { display: flex; align-items: center; gap: 14px; flex: 1 1 0; }

.top-header__hamburger {
    display: none;
    width: 35px;
    height: 35px;
    padding: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: none;
    border-radius: 50%;
    background: color-mix(in srgb, var(--on-brand) 22%, transparent);
    cursor: pointer;
    flex-shrink: 0;
}

.top-header__hamburger .line {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 10px;
    background: var(--on-brand);
    transition: transform 160ms ease;
}
.top-header__hamburger .line:nth-child(1) { width: 10px; transform: translateX(-3px); }
.top-header__hamburger .line:nth-child(3) { width: 10px; transform: translateX(3px); }
.top-header__hamburger:hover .line { transform: none; }

.top-header__date {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.25px;
    white-space: nowrap;
    color: var(--on-brand);
}

.top-header__date-icon { display: flex; }

.top-header__bell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    color: var(--on-brand);
    cursor: pointer;
}
.top-header__bell:hover { background: color-mix(in srgb, var(--on-brand) 14%, transparent); }
.top-header__bell:focus-visible { outline: 2px solid var(--on-brand); outline-offset: 2px; }

/* Filled in by platform.js; the grid display below would otherwise override [hidden]. */
.top-header__bell-count[hidden] { display: none; }

.top-header__bell-count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #e5484d;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
}

/* The display above outranks the browser's own rule for [hidden], so without this the empty
   badge still drew as a red dot when there was nothing unread. */
.top-header__bell-count[hidden] { display: none; }

/* -- Screen search -- */

.top-header__search {
    display: flex;
    align-items: center;
    gap: 7px;
    position: relative;
    flex: 0 1 280px;
    height: 37px;
    min-width: 0;
    padding: 4px 6px 4px 14px;
    border-radius: 26px;
    background: color-mix(in srgb, var(--on-brand) 27%, transparent);
    border: 1px solid color-mix(in srgb, var(--on-brand) 39%, transparent);
}

.top-header__search-icon { flex-shrink: 0; color: var(--on-brand); }

.top-header .top-header__search-input {
    flex: 1;
    min-width: 0;
    padding: 0 28px 0 0;
    border: none;
    outline: none;
    border-radius: 0;
    background: none;
    color: var(--on-brand);
    font: inherit;
    font-size: 11.375px;
}
.top-header .top-header__search-input::placeholder { color: color-mix(in srgb, var(--on-brand) 72%, transparent); }

.top-header__search-btn {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--on-brand);
    color: var(--brand);
    cursor: pointer;
}
.top-header__search-btn:hover { background: color-mix(in srgb, var(--on-brand) 85%, transparent); }

.nav-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 340px;
    max-width: 92vw;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 40;
}

.nav-search-dropdown__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 4px;
}

.nav-search-dropdown__title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.nav-search-dropdown__clear {
    padding: 0;
    border: none;
    background: none;
    color: var(--brand);
    font: inherit;
    font-size: 11px;
    cursor: pointer;
}
.nav-search-dropdown__clear:hover { text-decoration: underline; }

.nav-search-dropdown__list {
    list-style: none;
    margin: 0;
    padding: 4px 6px;
    max-height: 320px;
    overflow-y: auto;
}

.nav-search-dropdown__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--ink);
    font-size: 13px;
    text-decoration: none;
}
.nav-search-dropdown__link:hover,
.nav-search-dropdown__item.is-active .nav-search-dropdown__link {
    background: var(--brand-soft);
    text-decoration: none;
}

.nav-search-dropdown__text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-search-dropdown__badge { flex-shrink: 0; font-size: 11px; color: var(--ink-3); }

.nav-search-dropdown__empty {
    padding: 18px 14px;
    text-align: center;
    font-size: 13px;
    color: var(--ink-3);
}

.nav-search-dropdown__hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--ink-3);
}

.nav-search-dropdown__hint kbd {
    padding: 1px 5px;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    background: var(--surface-2);
    font-family: inherit;
    font-size: 10px;
    color: var(--ink-2);
}

/* -- Right-hand cluster -- */

.top-header__right { display: flex; align-items: center; justify-content: flex-end; gap: 21px; flex: 1 1 0; }

.theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 68px;
    height: 35px;
    padding: 0 11px;
    border: none;
    border-radius: 50px;
    background: color-mix(in srgb, var(--on-brand) 90%, transparent);
    cursor: pointer;
    flex-shrink: 0;
}
.theme-toggle.is-dark { background: #2b2b2b; }

.theme-toggle__icon { z-index: 1; display: flex; }
.theme-toggle .theme-toggle__light { color: #f4f6f8; }
.theme-toggle .theme-toggle__dark { color: #2b2b2b; }
.theme-toggle.is-dark .theme-toggle__light { color: #9aa4b1; }
.theme-toggle.is-dark .theme-toggle__dark { color: #f4f6f8; }

.theme-toggle__knob {
    position: absolute;
    top: 3px;
    left: 5px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--brand);
    transition: left 200ms ease;
}
.theme-toggle.is-dark .theme-toggle__knob { left: 35px; }

.profile-dropdown { position: relative; }

.profile-button {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3.5px 7px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--on-brand);
    font: inherit;
    cursor: pointer;
}
.profile-button:hover { background: color-mix(in srgb, var(--on-brand) 12%, transparent); }

.profile-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--on-brand) 25%, transparent);
    color: var(--on-brand);
    font-size: 11.375px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.profile-name { font-size: 14px; font-weight: 500; white-space: nowrap; }
.profile-chevron { transition: transform 160ms ease; }
.profile-button[aria-expanded="true"] .profile-chevron { transform: rotate(180deg); }

/* --- Account menu ----------------------------------------------------------------------------
   One panel with inset rows: every row hovers as a rounded pill inside the panel rather than a
   full-width band, and every row leads with a 28px tile — initials for a company, an icon for an
   action — so the menu reads as a list of places and things to do. Shared by the platform and
   workspace top bars; colours come from the theme tokens, so dark mode follows on its own. */

.profile-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 300px;
    max-width: calc(100vw - 24px);
    /* The whole panel scrolls only when the window is too short for it — never a box inside it. */
    max-height: calc(100vh - var(--topbar-height) - 16px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    padding: 8px;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgb(16 22 28 / 6%), 0 16px 40px -8px rgb(16 22 28 / 20%);
    z-index: 40;
    transform-origin: top right;
    animation: profile-menu-open 140ms ease-out;
}

@keyframes profile-menu-open {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .profile-menu { animation: none; }
}

/* Who and where: avatar, name and address on one line, the context pill under them. */
/* A softly tinted card, so "who and where" reads as one thing above the list. */
.profile-menu__header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border-radius: 12px;
    background: color-mix(in srgb, var(--brand) 6%, var(--surface));
}

.profile-menu__identity {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    width: 100%;
}

.profile-menu__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--brand-gradient);
    color: var(--on-brand);
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px color-mix(in srgb, var(--brand) 25%, transparent);
}

.profile-menu__who { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.profile-menu__who strong {
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.profile-menu__who small {
    font-size: 11.5px;
    color: var(--ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-menu__divider { height: 1px; margin: 8px 6px; background: var(--border); }

/* The context pill, in ZenflowHR's platform colours rather than the page blue, so "which side of
   the product am I on" is answered by colour and not only by the word. */
.context-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f3e8ff;
    color: #7c3aed;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Rows: actions (Two-step sign-in, Sign out) and places (Switch Context) share one shape. */
.profile-menu__item,
.context-switch__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 42px;
    padding: 6px 10px;
    border: none;
    border-radius: 10px;
    background: none;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease;
}

.profile-menu__item:hover,
.context-switch__item:hover { background: var(--brand-soft); color: var(--brand); }

.profile-menu__item:focus-visible,
.context-switch__item:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }

/* The leading tile: an icon for an action, initials for a company. */
.profile-menu__icon,
.context-switch__tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--ink) 6%, transparent);
    color: var(--ink-2);
    transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.context-switch__tile { font-size: 11px; font-weight: 700; letter-spacing: 0.02em; }
.context-switch__tile .bi { font-size: 14px; }

/* Each company keeps its own colour, from a hue the view derives from its name — the same
   company is the same colour on every page, and two companies are easy to tell apart. */
.context-switch__tile--company {
    background: hsl(var(--tile-hue, 215) 80% 93%);
    color: hsl(var(--tile-hue, 215) 55% 34%);
}

.profile-menu__item:hover .profile-menu__icon,
.context-switch__item:hover .context-switch__tile:not(.context-switch__tile--company),
.context-switch__item--current .context-switch__tile {
    background: color-mix(in srgb, var(--brand) 14%, transparent);
    color: var(--brand);
}

.context-switch__item:hover .context-switch__tile--company { transform: scale(1.06); }

@media (prefers-reduced-motion: reduce) {
    .context-switch__item:hover .context-switch__tile--company { transform: none; }
}

.profile-menu__item--danger,
.profile-menu__item--danger .profile-menu__icon { color: var(--danger); }
.profile-menu__item--danger:hover { background: var(--danger-soft); color: var(--danger); }
.profile-menu__item--danger:hover .profile-menu__icon {
    background: color-mix(in srgb, var(--danger) 14%, transparent);
    color: var(--danger);
}

/* "Switch Context": a quiet heading, a small label per group (Tenant Owner, Staff, Platform),
   rows under each, and the current place tinted with a tick. No inner scroll box: when the list
   is longer than the window, the whole panel scrolls. */
.context-switch__title {
    display: block;
    padding: 4px 10px 2px;
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 600;
}

.context-switch__group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 10px 4px;
    color: var(--ink-3);
    font-size: 11px;
    font-weight: 500;
}
.context-switch__group .bi { font-size: 11.5px; }

.context-switch form { margin: 0; }

.context-switch__name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Trailing mark: a chevron where a row goes somewhere, a tick where the person already is. The
   chevron only shows on hover or focus, so a long list stays calm. */
.context-switch__end { flex-shrink: 0; font-size: 12px; color: var(--ink-3); opacity: 0; transition: opacity 120ms ease; }
.context-switch__item:hover .context-switch__end,
.context-switch__item:focus-visible .context-switch__end { opacity: 1; color: var(--brand); }

.context-switch__item--current,
.context-switch__item--current:hover { background: var(--brand-soft); color: var(--brand); cursor: default; font-weight: 500; }
.context-switch__item--current .context-switch__end { opacity: 1; font-size: 15px; color: var(--brand); }

/* A Staff entry: the staff member's name, and the company they work in beneath it. */
.context-switch__name--stacked {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.context-switch__name--stacked > span {
    overflow: hidden;
    text-overflow: ellipsis;
}
.context-switch__sub {
    color: var(--ink-3);
    font-size: 11.5px;
    font-weight: 400;
}

/* --- Page header ---------------------------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.page-header__text { min-width: 0; }
.page-header__actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.page-header__actions:empty { display: none; }

.badge {
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--ink-2);
    white-space: nowrap;
}
.badge-env { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.main { padding: 22px 20px calc(40px + env(safe-area-inset-bottom, 0px)); }

/* The content is its own white panel floating on the page, the way ZenflowHR draws every screen
   (`.sidebar + main .content` in its layout.css): rounded, shadowed, and inset from the edges so
   the page colour frames it. Without it the screen was one flat surface with cards on it, which
   is the difference that read as "the background is not the same". Same 641px floor ZenflowHR
   uses — below that the panel's margin would eat the little width a phone has. */
@media (min-width: 641px) {
    .main {
        background: var(--surface);
        border-radius: 30px;
        margin: 15px;
        padding: 10px 21px calc(21px + env(safe-area-inset-bottom, 0px));
        box-shadow: var(--shadow-panel);
        overflow-x: hidden;
    }
}

/* Pushed to the foot of the column on a short screen; on a long one it simply follows the panel. */
.app-footer {
    margin-top: auto;
    padding: 0 16px calc(12px + env(safe-area-inset-bottom, 0px));
    text-align: center;
    color: var(--ink-3);
}
.app-footer a { color: var(--brand); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* --- Cards and grids ---------------------------------------------------------------------- */

.grid { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card-body { padding: 16px; }
.card-body.is-flush { padding: 0; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; }
.stat-hint { font-size: 12px; color: var(--ink-3); }

/* --- Tables ------------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

th {
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-3);
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }

.empty {
    padding: 44px 20px;
    text-align: center;
    color: var(--ink-3);
}

/* --- Status pills --------------------------------------------------------------------------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-neutral { background: var(--surface-2); color: var(--ink-2); }
.pill-brand { background: var(--brand-soft); color: var(--brand); }

/* --- Forms and buttons ----------------------------------------------------------------------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

/* A date field is a text field that happens to open a calendar, so it is listed
   here with the rest. Left out, it kept the browser's own box and sat among the
   platform's fields looking like a control from another screen — which is how
   "Date received" ended up half a head shorter than the amount beside it. The
   picker itself follows :root's color-scheme, so no dark values are needed. */
input[type="text"], input[type="search"], input[type="number"], input[type="date"],
select, textarea {
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    min-width: 0;
}

/* The calendar button is the only affordance on the field, so it says it is
   clickable rather than sitting at full strength and reading as an icon. */
input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.55;
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:focus::-webkit-calendar-picker-indicator { opacity: 1; }

input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible,
a.nav-link:focus-visible, a.menu-link:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.btn {
    font: inherit;
    font-weight: 550;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { filter: brightness(1.06); background: var(--brand); }

.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm { padding: 4px 10px; font-size: 12.5px; }

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13.5px;
}
.alert-success { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert-warning { background: var(--warn-soft); color: var(--warn); }

/* A validation summary with nothing to say still renders: the tag helper marks it
   validation-summary-valid and leaves a <ul> holding one hidden <li>, so it is not
   :empty and the .alert-error background showed as a red bar over every form the
   moment it opened. Hide it until it has something in it. */
.validation-summary-valid { display: none; }

/* And when it does have something, the browser's own list indent puts the messages
   a long way in from the edge of the bar. */
.alert ul { margin: 0; padding-left: 18px; }
.alert li + li { margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 550; }
.field .hint { font-size: 12px; color: var(--ink-3); }

.definition { display: grid; grid-template-columns: minmax(120px, 190px) 1fr; gap: 10px 16px; }
.definition dt { color: var(--ink-3); font-size: 13px; }
.definition dd { margin: 0; font-size: 13.5px; }

.pagination { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }

/* --- Tabs ------------------------------------------------------------------------------------ */

/* A screen whose sections are each a form of their own — billing settings — shows one section at
   a time, the way ZenflowHR's does. The strip is a row of ordinary links so the tabs still work
   with no javascript: each one asks the server for the screen on that tab. */

.tabs-strip {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    scrollbar-width: none;
}
.tabs-strip::-webkit-scrollbar { height: 0; }

.tab {
    flex-shrink: 0;
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 550;
    color: var(--ink-2);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.tab:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.tab.is-active {
    color: var(--brand);
    background: var(--brand-soft);
    border-bottom-color: var(--brand);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* The row a tab's save button sits in, under the card rather than inside it. */
.tab-actions { display: flex; gap: 10px; margin-top: 16px; }

/* --- Sparkline ------------------------------------------------------------------------------- */

.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 48px; }
.sparkline span {
    flex: 1;
    background: var(--brand);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
    opacity: 0.85;
}

/* --- Responsive -------------------------------------------------------------------------------- */

@media (max-width: 1100px) {
    .col-3 { grid-column: span 6; }
    .col-4 { grid-column: span 6; }
    .col-5, .col-7, .col-8 { grid-column: span 12; }
}

@media (max-width: 860px) {
    .top-header__hamburger { display: flex; }
    .sidebar-collapse { display: none; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform 160ms ease;
        box-shadow: var(--shadow);
    }


    .sidebar.is-open { transform: none; }

    .col-3, .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 12; }

    .definition { grid-template-columns: 1fr; gap: 2px 0; }
    .definition dd { margin-bottom: 10px; }
}

/* --- Top header, narrow screens ---------------------------------------------------------------- */

@media (max-width: 1100px) {
    .top-header__search { flex: 0 1 220px; }
}

@media (max-width: 1000px) {
    .top-header__date { display: none; }
}

@media (max-width: 860px) {
    .top-header { padding-left: 14px; padding-right: 12px; }
    .top-header__right { gap: 10px; }
}

@media (max-width: 680px) {
    .profile-name { display: none; }
    .top-header__search { flex: 0 1 154px; }
}

@media (max-width: 520px) {
    .top-header__search { display: none; }
}

/* --- Permission picker and checkbox lists ------------------------------------------------------ */

.checkbox-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
    font-size: 13.5px;
    font-weight: 400;
    cursor: pointer;
}

.checkbox-line input { margin-top: 3px; flex: 0 0 auto; }

/* The role form has a page to itself, so the groups sit side by side rather than in a scroll box. */
.permission-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 18px 24px;
    align-items: start;
}

.permission-group { border: none; margin: 0; padding: 0; min-width: 0; }

.permission-group legend {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    padding: 0;
    margin-bottom: 4px;
}

.permission-hint { display: block; font-size: 12px; line-height: 1.4; }

.permission-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

details > summary { cursor: pointer; font-size: 13.5px; }
details[open] > summary { margin-bottom: 6px; }

.rule { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

/* --- Audit viewer ------------------------------------------------------------------------------ */

.audit-filters select,
.audit-filters input[type="date"] { max-width: 180px; }

pre.json {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 6px 0 0;
}

.diff-before { color: var(--danger); text-decoration: line-through; opacity: 0.85; }
.diff-after { color: var(--ok); font-weight: 550; }

/* --- Settings screens -------------------------------------------------------------------------- */

tbody tr.is-selected { background: var(--brand-soft); }
tbody tr.is-selected td { border-bottom-color: var(--border-strong); }

textarea { font: inherit; line-height: 1.5; resize: vertical; }

code.mono {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12px;
}

/* --- Two-step sign-in (Account/Security) ---------------------------------------------------- */

.security-page .card-body p { margin: 0 0 12px; }
.security-page .card-body p:last-child { margin-bottom: 0; }

.security-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.security-actions form { margin: 0; }

.security-method {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
}
.security-method + .security-method { border-top: 1px solid var(--border); }
.security-method form { margin: 0; }

.security-qr { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
/* A white quiet zone round the code, in dark mode too: scanners need the contrast. */
.security-qr img { background: #ffffff; padding: 8px; border-radius: 8px; border: 1px solid var(--border); }
.security-qr > div { flex: 1 1 220px; }
.security-secret { font-size: 15px; letter-spacing: 0.06em; word-break: break-all; }

.security-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 24px;
    margin: 16px 0;
    padding: 16px 16px 16px 36px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
}
@media (max-width: 520px) { .security-codes { grid-template-columns: 1fr; } }

.security-error { color: var(--danger); font-size: 12.5px; }
.security-error ul { margin: 0; padding-left: 18px; }
.security-error:empty, .security-error.validation-summary-valid { display: none; }

/* --- Dark-mode tweaks for the account menu -------------------------------------------------- */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .context-badge { background: #2c1d4a; color: #c4a7ff; }
    :root:not([data-theme="light"]) .profile-menu { box-shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 16px 36px -8px rgb(0 0 0 / 60%); }
    :root:not([data-theme="light"]) .context-switch__tile--company { background: hsl(var(--tile-hue, 215) 35% 22%); color: hsl(var(--tile-hue, 215) 80% 78%); }
}

:root[data-theme="dark"] .context-badge { background: #2c1d4a; color: #c4a7ff; }
:root[data-theme="dark"] .profile-menu { box-shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 16px 36px -8px rgb(0 0 0 / 60%); }
:root[data-theme="dark"] .profile-menu__item--danger:hover { background: var(--danger-soft); }
:root[data-theme="dark"] .context-switch__tile--company { background: hsl(var(--tile-hue, 215) 35% 22%); color: hsl(var(--tile-hue, 215) 80% 78%); }

/* The page a workspace host shows when it cannot serve the request at all — no such workspace,
   not verified yet, or gone. Written by WorkspaceHostMiddleware before routing, so it is plain
   markup on this stylesheet alone. */
.gate-page { min-height: 100vh; display: grid; place-items: center; background: var(--bg); padding: 16px; }
.gate-card {
    max-width: 460px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    text-align: center;
}
.gate-card h1 { font-size: 20px; margin: 14px 0 8px; }
.gate-card p { color: var(--ink-2); margin: 0; }
