/* =====================================================================
   TPE-CTM — enterprise UI theme (shades of blue, clean typography)
   ===================================================================== */
:root {
    --blue-900: #0a2c5c;
    --blue-800: #0b3d7a;
    --blue-700: #0b4f9c;
    --blue-600: #1565c0;
    --blue-500: #1e88e5;
    --blue-400: #42a5f5;
    --blue-300: #90caf9;
    --blue-100: #e3f0fd;
    --blue-50: #f1f7fe;
    --ink-900: #0f172a;
    --ink-700: #334155;
    --ink-500: #64748b;
    --ink-300: #cbd5e1;
    --bg: #eef3fb;
    --surface: #ffffff;
    --line: #e2e8f0;
    --green: #16a34a;
    --amber: #d97706;
    --red: #dc2626;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-md: 0 6px 18px rgba(11, 79, 156, .10), 0 2px 6px rgba(15, 23, 42, .06);
    --shadow-lg: 0 24px 60px rgba(10, 44, 92, .22);
    --font: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

* {
    box-sizing: border-box
}

html,
body {
    margin: 0;
    min-height: 100%
}

body {
    font-family: var(--font);
    color: var(--ink-900);
    background: var(--bg);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased
}

/* Root app container: flex column so footer always stays at bottom */
#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh
}

a {
    color: var(--blue-700);
    text-decoration: none
}

h1,
h2,
h3,
h4 {
    margin: 0;
    font-weight: 650;
    letter-spacing: -.01em
}

.hidden {
    display: none !important
}

.muted {
    color: var(--ink-500)
}

.spacer {
    flex: 1
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: .15s;
    font-family: inherit;
    background: #fff;
    color: var(--ink-700);
    white-space: nowrap
}

.btn:hover {
    transform: translateY(-1px)
}

.btn:active {
    transform: translateY(0)
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
    color: #fff;
    box-shadow: var(--shadow-sm)
}

.btn-primary:hover {
    box-shadow: var(--shadow-md)
}

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--ink-700)
}

.btn-ghost:hover {
    background: var(--blue-50);
    border-color: var(--blue-300)
}

.btn-danger {
    background: #fff;
    color: var(--red);
    border-color: #fecaca
}

.btn-danger:hover {
    background: #fef2f2
}

.btn-sm {
    padding: 6px 11px;
    font-size: 13px
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    transform: none
}

.btn-block {
    width: 100%;
    justify-content: center
}

/* ---------- Inputs ---------- */
.field {
    margin-bottom: 16px
}

.field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-700);
    margin-bottom: 6px
}

.field .req {
    color: var(--red)
}

input,
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--ink-900);
    background: #fff;
    transition: .15s;
    outline: none
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-100)
}

textarea {
    resize: vertical;
    min-height: 72px
}

.checkrow {
    display: flex;
    align-items: center;
    gap: 9px
}

.checkrow input {
    width: auto
}

a.disabled {
    color: var(--ink-500);
    pointer-events: none;
    cursor: default;
    text-decoration: none
}

.hint {
    font-size: 12px;
    color: var(--ink-500);
    margin-top: 5px
}

.err-text {
    color: var(--red);
    font-size: 12px;
    margin-top: 5px
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0 18px
}

@media(max-width:720px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr
    }
}

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm)
}

/* ---------- Auth / setup centered layout ---------- */
.center-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(1200px 600px at 10% -10%, #1e88e5 0%, transparent 50%),
        radial-gradient(1000px 700px at 110% 110%, #0a2c5c 0%, transparent 45%),
        linear-gradient(135deg, var(--blue-900), var(--blue-700))
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden
}

.auth-card.wide {
    max-width: 760px
}

.auth-head {
    padding: 30px 34px 18px
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px
}

.brand .logo {
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--blue-700), var(--blue-400));
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: 17px;
    box-shadow: var(--shadow-md)
}

.brand .name {
    font-size: 18px;
    font-weight: 750;
    color: var(--blue-900)
}

.brand .sub {
    font-size: 11.5px;
    color: var(--ink-500);
    font-weight: 500
}

.auth-body {
    padding: 8px 34px 30px
}

.auth-title {
    font-size: 21px;
    margin-bottom: 4px
}

.auth-sub {
    color: var(--ink-500);
    margin-bottom: 22px;
    font-size: 13.5px
}

/* ---------- Setup stepper ---------- */
.stepper {
    display: flex;
    gap: 6px;
    padding: 0 34px 6px
}

.step {
    flex: 1;
    height: 5px;
    border-radius: 99px;
    background: var(--blue-100)
}

.step.active {
    background: linear-gradient(90deg, var(--blue-600), var(--blue-400))
}

.step.done {
    background: var(--green)
}

.step-label {
    padding: 18px 34px 0;
    font-size: 12px;
    color: var(--ink-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em
}

/* ---------- App shell ---------- */
.shell {
    display: grid;
    grid-template-columns: 256px 1fr;
    flex: 1 1 auto;
    min-height: 0
}

.sidebar {
    background: linear-gradient(180deg, var(--blue-900), var(--blue-800));
    color: #dbe9fb;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh
}

.sidebar .brand {
    padding: 20px 20px 14px;
    margin: 0
}

.sidebar .brand .name {
    color: #fff
}

.nav-search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 12px 10px;
    padding: 8px 12px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .08)
}

.nav-search-ico {
    opacity: .75;
    font-size: 13px;
    flex: 0 0 auto
}

.nav-search-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 13px
}

.nav-search-input::placeholder {
    color: #9fc0ea
}

.nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px
}

.nav-group {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #7fa6d9;
    margin: 16px 12px 6px;
    font-weight: 700
}

.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 9px;
    color: #cfe0f7;
    font-weight: 550;
    font-size: 13.5px;
    margin-bottom: 2px
}

.nav a:hover {
    background: rgba(255, 255, 255, .08);
    color: #fff
}

.nav a.active {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
    color: #fff;
    box-shadow: var(--shadow-sm)
}

.nav a .ico {
    width: 18px;
    text-align: center;
    opacity: .95
}

.side-foot {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, .12);
    font-size: 12px;
    color: #9fc0ea
}

.app-footer {
    width: 100%;
    background: var(--blue-900);
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding: 8px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    flex-shrink: 0
}

.app-footer-brand {
    color: #cfe0f7;
    font-weight: 700;
    font-size: 12.5px;
    text-decoration: none;
    white-space: nowrap
}

.app-footer-brand:hover {
    color: #fff;
    text-decoration: underline
}

.app-footer-disclaimer {
    font-size: 11px;
    color: #7fa6d9;
    line-height: 1.4
}

.app-footer-disclaimer a {
    color: #7fa6d9;
    text-decoration: underline
}

.app-footer-disclaimer a:hover {
    color: #cfe0f7
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0
}

.topbar {
    height: 50px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 20;
    overflow: visible
}

/* Module buttons get their own full-width row below the topbar, so they
   never compete with Help/notifications/the user menu for space — the row
   wraps onto a second line on narrow screens instead of clipping or
   requiring a scrollbar. */
.topbar-modules {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--blue-50);
    border-bottom: 1px solid var(--line)
}

.topbar-search {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 6px 16px;
    position: sticky;
    top: 50px;
    z-index: 19;
    display: flex;
    align-items: center;
    gap: 8px
}

.topbar-search input {
    width: 100%;
    max-width: 480px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--ink-900);
    background: var(--blue-50);
    outline: none;
    transition: .15s
}

.topbar-search input:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-100);
    background: #fff
}

.topbar h2 {
    font-size: 17px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0
}

.topbar .userbox .um,
.topbar .userbox .ur {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

@media(max-width:480px) {
    .topbar {
        padding: 0 12px;
        gap: 10px
    }

    .topbar .userbox>div:not([class]) {
        display: none
    }
}

.menu-btn {
    display: none
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-600), var(--blue-400));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    cursor: pointer
}

.userbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    position: relative
}

.userbox .um {
    font-size: 13px;
    font-weight: 600
}

.userbox .ur {
    font-size: 11px;
    color: var(--ink-500)
}

.dropdown {
    position: absolute;
    right: 0;
    top: 46px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    min-width: 180px;
    padding: 6px;
    z-index: 40
}

.dropdown a {
    display: block;
    padding: 9px 12px;
    border-radius: 7px;
    color: var(--ink-700);
    font-size: 13.5px
}

.dropdown a:hover {
    background: var(--blue-50)
}

.content {
    padding: 24px;
    overflow: auto
}

.page-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap
}

.page-head h1 {
    font-size: 22px
}

.page-head .desc {
    color: var(--ink-500);
    font-size: 13px
}

/* ---------- Stat tiles ---------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px
}

@media(max-width:900px) {
    .tiles {
        grid-template-columns: 1fr 1fr
    }
}

.tile {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    gap: 14px;
    align-items: center
}

.tile .ti {
    width: 46px;
    height: 46px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 20px;
    background: var(--blue-100);
    color: var(--blue-700)
}

.tile .tv {
    font-size: 26px;
    font-weight: 750;
    line-height: 1
}

.tile .tl {
    font-size: 12.5px;
    color: var(--ink-500);
    margin-top: 3px
}

/* ---------- Table ---------- */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap
}

.search {
    position: relative;
    flex: 1;
    max-width: 340px
}

.search input {
    padding-left: 34px
}

.search .si {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-500)
}

.table-wrap {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm)
}

table {
    width: 100%;
    border-collapse: collapse
}

thead th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-500);
    background: var(--blue-50);
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
    white-space: nowrap
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 13.5px
}

tbody tr:last-child td {
    border-bottom: none
}

tbody tr:hover {
    background: var(--blue-50)
}

.row-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end
}

.empty {
    padding: 48px;
    text-align: center;
    color: var(--ink-500)
}

.pager {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 12px 4px;
    font-size: 13px;
    color: var(--ink-500)
}

.pager-size,
.pager-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
}

.page-size-select {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    font-size: 13px;
    background: var(--surface);
    color: inherit;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 11.5px;
    font-weight: 650
}

.badge-green {
    background: #dcfce7;
    color: #15803d
}

.badge-gray {
    background: #f1f5f9;
    color: #475569
}

.badge-blue {
    background: var(--blue-100);
    color: var(--blue-700)
}

.badge-amber {
    background: #fef3c7;
    color: #b45309
}

.badge-pink {
    background: #fce7f3;
    color: #be185d
}

.badge-yellow {
    background: #fef9c3;
    color: #854d0e
}

.badge-red {
    background: #fee2e2;
    color: #b91c1c
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px
}

.chip {
    background: var(--blue-100);
    color: var(--blue-700);
    border-radius: 99px;
    padding: 2px 9px;
    font-size: 11.5px;
    font-weight: 600
}

/* ---------- Modal ---------- */
.overlay,
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 44, 92, .45);
    backdrop-filter: blur(2px);
    display: grid;
    place-items: center;
    z-index: 100;
    padding: 20px;
    overflow: auto
}

.modal {
    background: #fff;
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: pop .18s ease
}

.modal.lg {
    max-width: 820px
}

.modal.xl {
    max-width: 1120px
}

@keyframes pop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98)
    }

    to {
        opacity: 1;
        transform: none
    }
}

.modal-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center
}

.modal-head h2,
.modal-head h3 {
    font-size: 17px;
    margin: 0
}

.modal-head .x,
.modal-head .close-btn {
    margin-left: auto;
    cursor: pointer;
    color: var(--ink-500);
    font-size: 20px;
    line-height: 1;
    background: none;
    border: none
}

.modal-body {
    padding: 20px 22px;
    overflow: auto
}

.modal-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    display: flex;
    gap: 10px;
    justify-content: flex-end
}

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    flex-wrap: wrap
}

.tab {
    padding: 9px 14px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px
}

.tab.active {
    color: var(--blue-700);
    border-bottom-color: var(--blue-600)
}

/* ---------- QR / 2FA ---------- */
.qr-box {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
    background: var(--blue-50);
    border: 1px solid var(--blue-100);
    border-radius: 12px;
    padding: 18px
}

.qr-box .qr {
    background: #fff;
    padding: 10px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm)
}

.qr-box svg {
    display: block;
    width: 160px;
    height: 160px
}

.secret {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    background: #fff;
    border: 1px dashed var(--blue-300);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    word-break: break-all;
    letter-spacing: 1px
}

.otp-input {
    letter-spacing: 10px;
    text-align: center;
    font-size: 22px;
    font-weight: 700
}

/* ---------- Toast ---------- */
.toasts {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px
}

.toast {
    background: #fff;
    border-left: 4px solid var(--blue-600);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    padding: 13px 16px;
    min-width: 260px;
    max-width: 380px;
    animation: slide .2s ease;
    font-size: 13.5px
}

.toast.success {
    border-left-color: var(--green)
}

.toast.error {
    border-left-color: var(--red)
}

.toast.warning {
    border-left-color: var(--amber, #d97706)
}

.toast .tt {
    font-weight: 700;
    margin-bottom: 2px
}

@keyframes slide {
    from {
        opacity: 0;
        transform: translateX(20px)
    }

    to {
        opacity: 1;
        transform: none
    }
}

/* ---------- Tree (reporting) ---------- */
.tree {
    list-style: none;
    padding-left: 0;
    margin: 0
}

.tree ul {
    list-style: none;
    padding-left: 24px;
    border-left: 2px dashed var(--blue-100);
    margin: 4px 0 4px 10px
}

.tree li {
    margin: 4px 0
}

.tnode {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 7px 12px;
    box-shadow: var(--shadow-sm)
}

.tnode .tav {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--blue-100);
    color: var(--blue-700);
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700
}

/* ---------- Responsive sidebar ---------- */
/* Hidden outside the mobile breakpoint (and by default within it too — see
   the sibling-selector rule below) so the scrim element every shell mounts
   next to its sidebar never occupies layout space or blocks clicks on
   desktop. */
.scrim {
    display: none
}

@media(max-width:860px) {
    .shell {
        grid-template-columns: 1fr
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 256px;
        z-index: 60;
        transform: translateX(-100%);
        transition: .22s
    }

    .sidebar.open {
        transform: none;
        box-shadow: var(--shadow-lg)
    }

    .menu-btn {
        display: inline-grid
    }

    /* Only shown while the drawer is open (sibling of .sidebar.open) — tapping
       it closes the drawer, matching the nav-link-closes-it behavior instead
       of only that. */
    .sidebar.open~.scrim {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(10, 44, 92, .4);
        z-index: 55
    }
}

/* ---------- Business Copilot chat (rendered Markdown-lite replies) ---------- */
.copilot-md > *:first-child {
    margin-top: 0
}

.copilot-md > *:last-child {
    margin-bottom: 0
}

.copilot-md p {
    margin: 0 0 8px;
    white-space: pre-wrap
}

.copilot-md h3,
.copilot-md h4,
.copilot-md h5,
.copilot-md h6 {
    margin: 10px 0 6px;
    line-height: 1.3
}

.copilot-md ul,
.copilot-md ol {
    margin: 0 0 8px;
    padding-left: 20px
}

.copilot-md li {
    margin: 2px 0
}

.copilot-md code {
    background: rgba(15, 23, 42, .08);
    border-radius: 4px;
    padding: 1px 5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .92em
}

.copilot-md pre {
    background: rgba(15, 23, 42, .08);
    border-radius: var(--radius-sm, 8px);
    padding: 10px 12px;
    overflow-x: auto;
    margin: 0 0 8px
}

.copilot-md pre code {
    background: none;
    padding: 0
}

.copilot-md-table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 8px;
    font-size: .93em
}

.copilot-md-table th,
.copilot-md-table td {
    border: 1px solid var(--line);
    padding: 4px 8px;
    text-align: left
}

.copilot-md-table th {
    background: rgba(15, 23, 42, .05)
}

/* ---------- Collaborate chat (mobile-responsive) ---------- */
.chat-sidebar-col {
    display: flex;
    flex-direction: column;
    width: 280px;
    flex-shrink: 0
}

.chat-back-btn {
    display: none
}

@media(max-width:760px) {
    .content:has(.chat-root) {
        padding: 0
    }

    .chat-root {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        height: calc(100vh - 130px);
        height: calc(100dvh - 130px)
    }

    .chat-sidebar-col {
        width: 100%
    }

    .chat-root:not(.has-active-conv) .chat-thread {
        display: none
    }

    .chat-root.has-active-conv .chat-sidebar-col {
        display: none
    }

    .chat-back-btn {
        display: inline-flex
    }

    .chat-thread-head {
        flex-wrap: wrap;
        row-gap: 6px
    }
}

/* ---------- Asset Locator canvas editor (mobile-responsive) ---------- */
/* Desktop layout is a fixed-width three-column flex row set via inline
   styles (canvas editor predates a class-based layout); stack it instead of
   squeezing the canvas into a sliver on narrow screens, same treatment as
   the Collaborate chat window above. The !important overrides are the
   pragmatic fix for the inline widths/heights rather than rewriting the
   editor's layout to be class-driven. */
@media(max-width:860px) {
    .content:has(.al-editor-body) {
        padding: 8px
    }

    .al-editor-body {
        flex-direction: column !important;
        height: auto !important
    }

    .al-editor-panel {
        width: 100% !important;
        max-height: 180px
    }

    .al-editor-stage {
        height: 50vh;
        min-height: 320px
    }
}

.loading {
    display: grid;
    place-items: center;
    min-height: 60vh;
    color: var(--ink-500)
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--blue-100);
    border-top-color: var(--blue-600);
    border-radius: 50%;
    animation: spin .8s linear infinite
}

@keyframes spin {
    to {
        transform: rotate(360deg)
    }
}

/* ---------- Notification Bell ---------- */
.notif-bell {
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    margin-right: 4px
}

.notif-bell:hover {
    background: var(--blue-50)
}

.notif-icon {
    font-size: 20px;
    line-height: 1
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: #fff;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    pointer-events: none
}

.notif-badge.hidden {
    display: none
}

.notif-popup {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    max-height: 400px;
    display: flex;
    flex-direction: column;
    overflow: hidden
}

.notif-popup.hidden {
    display: none
}

/* Scrolls independently so the "Mark all read" footer stays pinned when the
   notification list is taller than the popup's max-height. */
.notif-list {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0
}

.notif-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background .12s
}

.notif-item:last-child {
    border-bottom: none
}

.notif-item:hover {
    background: var(--blue-50)
}

.notif-item.unread {
    background: #eff6ff
}

.notif-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--ink-900);
    margin-bottom: 2px
}

.notif-body {
    font-size: 12px;
    color: var(--ink-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis
}

.notif-time {
    font-size: 11px;
    color: var(--ink-400);
    margin-top: 3px
}

.notif-empty {
    padding: 20px;
    text-align: center;
    color: var(--ink-400);
    font-size: 13px
}

.notif-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: center;
    flex-shrink: 0
}

/* ---------- Calendar grid ---------- */
.cal-day {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .1s
}

.cal-day:hover {
    filter: brightness(0.9)
}

/* ---------- Access Control permission matrix ---------- */
.tab-btn {
    padding: 8px 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    color: var(--ink-600);
    transition: background .12s
}

.tab-btn.active {
    background: var(--blue-600);
    color: #fff;
    border-color: var(--blue-600)
}

.perm-table {
    width: 100%;
    border-collapse: collapse
}

.perm-table th,
.perm-table td {
    padding: 6px 8px;
    font-size: 13px;
    border-bottom: 1px solid var(--line)
}

.perm-table th {
    background: var(--blue-50);
    font-weight: 600;
    text-align: center
}

.perm-table th:first-child {
    text-align: left
}

.perm-group-hdr td {
    background: var(--ink-900);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    padding: 4px 8px;
    letter-spacing: .04em
}

.perm-label {
    color: var(--ink-700)
}

.perm-cell {
    text-align: center
}

.perm-cell input[type=checkbox] {
    width: 16px;
    height: 16px;
    cursor: pointer
}

/* Consistent, aligned checkboxes & radios across all forms (esp. compliance). */
input[type=checkbox],
input[type=radio] {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    margin: 0;
    cursor: pointer;
    accent-color: var(--blue-600);
    vertical-align: middle;
    position: relative;
    top: -1px;
}

/* A checkbox sitting inline with its label text: keep them baseline-aligned. */
label>input[type=checkbox],
label>input[type=radio] {
    margin-right: 8px
}

/* Consent notice bar (P12) — shown until the signed-in user records consent. */
.consent-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: #fef9c3;
    color: #854d0e;
    border-bottom: 1px solid #fde68a;
    padding: 10px 18px;
    font-size: 13.5px;
    line-height: 1.4;
}

.consent-bar .cb-ico {
    font-size: 18px;
    flex: 0 0 auto
}

.consent-bar .cb-msg {
    flex: 1;
    min-width: 220px
}

.consent-bar .cb-act {
    background: #854d0e;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex: 0 0 auto;
}

.consent-bar .cb-act:hover {
    background: #6b3d0a
}

@media (prefers-color-scheme:dark) {
    .consent-bar {
        background: #3f320a;
        color: #fde68a;
        border-bottom-color: #5a480f
    }

    .consent-bar .cb-act {
        background: #fde68a;
        color: #3f320a
    }
}

/* Legal hold notice bar (P8 enforcement) — shown on every page while a legal
   hold is active on the signed-in user's own account. */
.legal-hold-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: #fef9c3;
    color: #854d0e;
    border-bottom: 1px solid #fde68a;
    padding: 10px 18px;
    font-size: 13.5px;
    line-height: 1.4;
}

.legal-hold-bar .lhb-ico {
    font-size: 18px;
    flex: 0 0 auto
}

.legal-hold-bar .lhb-msg {
    flex: 1;
    min-width: 220px
}

@media (prefers-color-scheme:dark) {
    .legal-hold-bar {
        background: #3f320a;
        color: #fde68a;
        border-bottom-color: #5a480f
    }
}

/* Browser-capability warning (Collaborate) — dismissible notice when the
   current browser lacks WebRTC APIs the calls/screen-share features need. */
.browser-support-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: #fef9c3;
    color: #854d0e;
    border-bottom: 1px solid #fde68a;
    padding: 10px 18px;
    font-size: 13.5px;
    line-height: 1.4
}

.browser-support-bar .bsb-ico {
    font-size: 18px;
    flex: 0 0 auto
}

.browser-support-bar .bsb-msg {
    flex: 1;
    min-width: 220px
}

.browser-support-bar .bsb-close {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    opacity: .65
}

.browser-support-bar .bsb-close:hover {
    opacity: 1
}

@media (prefers-color-scheme:dark) {
    .browser-support-bar {
        background: #3f320a;
        color: #fde68a;
        border-bottom-color: #5a480f
    }
}

/* Post-login welcome banner ("Hey NAME, you have logged in after N Days") —
   shown once, on the first page rendered right after a fresh login. */
.welcome-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: #dbeafe;
    color: #1e40af;
    border-bottom: 1px solid #bfdbfe;
    padding: 10px 18px;
    font-size: 13.5px;
    line-height: 1.4;
}

.welcome-bar .wcb-ico {
    font-size: 18px;
    flex: 0 0 auto
}

.welcome-bar .wcb-msg {
    flex: 1;
    min-width: 220px
}

@media (prefers-color-scheme:dark) {
    .welcome-bar {
        background: #0f2a4a;
        color: #bfdbfe;
        border-bottom-color: #17385f
    }
}

/* Multiple-active-sessions notification — shown alongside the welcome banner
   when the signed-in account currently has more than one unrevoked session. */
.multi-device-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: #fef9c3;
    color: #854d0e;
    border-bottom: 1px solid #fde68a;
    padding: 10px 18px;
    font-size: 13.5px;
    line-height: 1.4;
}

.multi-device-bar .mdb-ico {
    font-size: 18px;
    flex: 0 0 auto
}

.multi-device-bar .mdb-msg {
    flex: 1;
    min-width: 220px
}

.multi-device-bar .mdb-act {
    background: #854d0e;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex: 0 0 auto;
}

.multi-device-bar .mdb-act:hover {
    background: #6b3d0a
}

@media (prefers-color-scheme:dark) {
    .multi-device-bar {
        background: #3f320a;
        color: #fde68a;
        border-bottom-color: #5a480f
    }

    .multi-device-bar .mdb-act {
        background: #fde68a;
        color: #3f320a
    }
}

/* Dismiss ("x") button shared by both post-login banners — inherits the
   bar's own text color so it works unchanged in both themes. Dismissing
   only hides it for the rest of this login; it reappears on next login
   since mountWelcomeBanner() is driven by a stash written at login time. */
.welcome-bar .banner-close,
.multi-device-bar .banner-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    opacity: .65;
    flex: 0 0 auto;
}

.welcome-bar .banner-close:hover,
.multi-device-bar .banner-close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, .08)
}

/* Consent form modal — PII catalog table + language picker. */
.consent-pii-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 6px
}

.consent-pii-table th,
.consent-pii-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top
}

.consent-pii-table th {
    background: var(--blue-50);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em
}

.consent-accept-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 12px;
    background: var(--blue-50);
    border-radius: 8px
}

.consent-accept-row label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600
}

/* =====================================================================
   Global API-activity bar — a thin multi-color strip pinned to the
   bottom of the viewport in every shell (mounted once by progress-bar.js,
   imported from api.js so it needs no per-page wiring). Always present;
   only animates while at least one request is in flight (any api()/
   downloadFile()/uploadFile() call — see timedFetch() in api.js).
   ===================================================================== */
#tpe-progress-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    max-height: 10px;
    z-index: 100000;
    background: linear-gradient(90deg, var(--blue-600), #8b5cf6, #ec4899, var(--amber), var(--green), #06b6d4, var(--blue-600));
    background-size: 300% 100%;
    opacity: .45;
    transition: height .2s ease, opacity .2s ease;
    pointer-events: none
}

#tpe-progress-bar.is-active {
    height: 6px;
    opacity: 1;
    animation: tpe-progress-flow 1.4s linear infinite
}

@keyframes tpe-progress-flow {
    0% { background-position: 0 50% }
    100% { background-position: 300% 50% }
}

@media (prefers-reduced-motion: reduce) {
    #tpe-progress-bar.is-active { animation: none }
}