:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --ink: #13233a;
    --muted: #607086;
    --line: #d9e1ec;
    --brand: #0b5cab;
    --brand-2: #11999e;
    --danger: #cf304a;
    --ok: #1a8755;
    --shadow: 0 10px 30px rgba(8, 33, 70, 0.08);
    --shadow-soft: 0 6px 18px rgba(8, 33, 70, 0.06);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", "Trebuchet MS", sans-serif;
    color: var(--ink);
    background: radial-gradient(circle at top right, #eaf4ff, transparent 40%), var(--bg);
}

a { color: var(--brand); text-decoration: none; }

.app-body {
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    gap: 10px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
    padding: 10px 18px 12px;
    margin: 0;
}

.topbar-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.topbar-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-top: 1px solid #e8eef7;
    padding-top: 8px;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img { width: 110px;  object-fit: contain; }
/* Keep header compact: logo only */
.brand span { display: none; }

.menu-toggle-btn {
    display: none;
    border: 1px solid #cfe0f3;
    border-radius: 8px;
    background: #fff;
    color: #0b5cab;
    padding: 8px 10px;
    align-items: center;
    gap: 8px;
}

.topnav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topnav > a,
.nav-group-toggle {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    font-size: 14px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.topnav > a.active,
.nav-group.active > .nav-group-toggle { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; border-color: transparent; }

.nav-group { position: relative; }
.nav-group-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 210px;
    display: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: var(--shadow-soft);
    padding: 6px;
    z-index: 30;
}
.nav-group:hover .nav-group-menu,
.nav-group.open .nav-group-menu { display: grid; gap: 4px; }
.nav-group-menu a {
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--ink);
    font-size: 13px;
    background: #fff;
}
.nav-group-menu a:hover,
.nav-group-menu a.active {
    background: #eef5ff;
    color: #0b5cab;
}

.userbox { text-align: right; min-width: 0; }
.userbox strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.userbox a { font-size: 13px; }

.quick-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.quick-link {
    font-size: 13px;
    padding: 7px 10px;
    border: 1px solid #cfe0f3;
    border-radius: 8px;
    background: #fff;
    color: #0b5cab;
    white-space: nowrap;
}
.quick-link-alert {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
}
.quick-link-alert.active {
    border-color: #0b5cab;
    background: #edf5ff;
}
.quick-link-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: #cf304a;
    line-height: 1;
}
.quick-link:hover {
    border-color: #0b5cab;
    background: #f1f7ff;
}
.quick-link-primary {
    border-color: #0b5cab;
    background: linear-gradient(90deg, #0b5cab, #11999e);
    color: #fff;
}
.quick-link-primary:hover {
    border-color: #0b5cab;
    background: linear-gradient(90deg, #0a4c91, #0f868a);
}
.quick-link-icon {
    min-width: 86px;
}

.top-modal {
    position: fixed;
    inset: 0;
    background: rgba(6, 18, 34, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1350;
}
.top-modal.active { display: flex; }
.top-modal-card {
    width: min(920px, 96vw);
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border: 1px solid #d9e1ec;
    border-radius: 14px;
    padding: 14px;
}
.top-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.top-modal-head h2 { margin: 0; }
.top-search-result {
    margin-top: 10px;
    border: 1px solid #d9e2f1;
    border-radius: 10px;
    max-height: 65vh;
    overflow: auto;
    padding: 10px;
}
.top-search-category { margin-bottom: 10px; }
.top-search-category h4 {
    margin: 4px 0 8px;
    font-size: 13px;
    color: #496079;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.top-search-item {
    display: block;
    border: 1px solid #e2ebf8;
    border-radius: 10px;
    padding: 8px 10px;
    margin-bottom: 6px;
    color: #12243d;
    background: #fbfdff;
}
.top-search-item:hover {
    border-color: #a8c0e8;
    background: #f1f7ff;
}
.top-search-item small {
    display: block;
    color: #607086;
    margin-top: 2px;
}

.container {
    max-width: 1360px;
    margin: 12px auto 0;
    padding: 12px 18px 32px;
    display: grid;
    gap: 16px;
}

.page-head {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    padding: 16px 18px;
}
.page-head h1 { margin: 0; font-size: 26px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.cards { display: grid; gap: 14px; }
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 18px;
}
.card h2, .card h3 { margin-top: 0; }
.card.stat strong { font-size: 34px; color: var(--brand); }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea, button {
    font: inherit;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}
textarea { resize: vertical; }

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); text-align: left; padding: 10px; font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
.table-wrap {
    margin-top: 10px;
    border: 1px solid #d9e1ec;
    border-radius: 10px;
    overflow: auto;
}

.btn {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    cursor: pointer;
}
.btn-primary { background: linear-gradient(90deg, var(--brand), var(--brand-2)); color: #fff; }
.w-full { width: 100%; }

.alert {
    margin: 10px 0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
}
.alert-error { background: #ffeaf0; color: #8e1f36; }
.alert-ok { background: #e8f8f0; color: #16623f; }

.cloud-link-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.cloud-link-list {
    margin-top: 8px;
    display: grid;
    gap: 6px;
}

.cloud-link-item {
    font-size: 13px;
    color: #425c79;
    background: #f4f8ff;
    border: 1px solid #d3dff0;
    border-radius: 8px;
    padding: 6px 8px;
}

.od-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(6, 18, 34, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1300;
}

.od-modal-overlay.active { display: flex; }

.od-modal-card {
    width: min(1100px, 96vw);
    max-height: 92vh;
    overflow: auto;
    background: #fff;
    border: 1px solid #d9e1ec;
    border-radius: 14px;
    padding: 14px;
}

.od-modal-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.od-modal-head h2 { margin: 0; }

.od-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 340px) auto auto 1fr;
    gap: 8px;
    align-items: end;
    margin-top: 10px;
}

.od-table-wrap {
    margin-top: 10px;
    border: 1px solid #d9e1ec;
    border-radius: 10px;
    overflow: hidden;
}

#cloudPickerTable td:first-child,
#cloudPickerTable th:first-child {
    width: 56px;
    text-align: center;
}

.od-item-name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.od-item-icon {
    font-size: 15px;
}

.od-item-icon-folder {
    color: #d39a2a;
}

.od-item-icon-file {
    color: #2e5f93;
}

.od-item-name-text {
    display: inline-block;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.od-type-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid #cddcf0;
}

.od-type-badge.folder {
    background: #fff8e9;
    color: #9a6a10;
    border-color: #f2d9a6;
}

.od-type-badge.file {
    background: #edf4ff;
    color: #244b72;
    border-color: #c9dbf5;
}

.flat-list, .timeline-list {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
}
.inline-edit { cursor: pointer; border-bottom: 1px dashed #90a1b8; }

.login-page {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(12px, 3vw, 20px);
    background: linear-gradient(130deg, #0a2947, #185f97, #1f7f7a);
}

.login-shell {
    width: min(1060px, 100%);
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    background: #fff;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 30px 50px rgba(4, 15, 31, 0.35);
}

.login-brand {
    padding: clamp(22px, 4vw, 36px);
    color: #fff;
    background: linear-gradient(170deg, #0a2d53, #11558c);
}
.login-brand h1 { margin: 8px 0 10px; line-height: 1.2; }
.login-brand p { margin: 0; max-width: 40ch; color: rgba(255, 255, 255, 0.9); }
.brand-logo { width: clamp(96px, 22vw, 180px); height: clamp(96px, 22vw, 180px); object-fit: contain; }
.login-card { padding: clamp(18px, 4vw, 36px); display: grid; align-content: center; }
.login-card h2 { margin-top: 0; margin-bottom: 10px; }
.login-card p { margin-top: 0; }

.teams-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1400;
    border: 1px solid #2e6fb8;
    border-radius: 999px;
    padding: 10px 14px;
    color: #fff;
    background: linear-gradient(120deg, #2b7cd3, #00a4bd);
    box-shadow: 0 12px 22px rgba(15, 54, 99, 0.35);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.teams-fab-badge {
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    background: #cf304a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}
.teams-fab.teams-fab-blink {
    animation: teamsFabBlink 1s ease-in-out infinite;
}
@keyframes teamsFabBlink {
    0%, 100% { box-shadow: 0 12px 22px rgba(15, 54, 99, 0.35); }
    50% { box-shadow: 0 0 0 6px rgba(207, 48, 74, 0.22), 0 12px 22px rgba(15, 54, 99, 0.35); }
}

.teams-widget {
    position: fixed;
    right: 18px;
    bottom: 74px;
    width: min(860px, calc(100vw - 26px));
    height: min(620px, calc(100vh - 120px));
    z-index: 1399;
    border: 1px solid #cddcf0;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 20px 46px rgba(9, 37, 74, 0.28);
    display: none;
    overflow: hidden;
}
.teams-widget.open {
    display: block;
}
.teams-widget-head {
    padding: 10px 12px;
    border-bottom: 1px solid #d9e1ec;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, #f3f9ff, #f7fcfd);
}
.teams-widget-head-actions {
    display: inline-flex;
    gap: 6px;
}
.teams-mobile-back-btn {
    display: none;
}
.teams-widget-body {
    height: calc(100% - 48px);
    display: grid;
    grid-template-columns: 280px 1fr;
}
.teams-widget-chats {
    border-right: 1px solid #e2e8f2;
    display: grid;
    grid-template-rows: auto auto 1fr;
    min-height: 0;
}
.teams-widget-search-wrap {
    padding: 10px;
    border-bottom: 1px solid #edf2f8;
}
.teams-widget-newchat {
    padding: 8px 10px;
    border-bottom: 1px solid #edf2f8;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: center;
}
.teams-widget-newchat input {
    min-height: 34px;
}
.teams-chat-list {
    overflow: auto;
    padding: 8px;
    display: grid;
    gap: 6px;
}
.teams-chat-item {
    width: 100%;
    text-align: left;
    border: 1px solid #dce5f2;
    border-radius: 10px;
    padding: 8px 10px;
    background: #fff;
    color: #123152;
    display: grid;
    gap: 4px;
    cursor: pointer;
}
.teams-chat-item strong {
    font-size: 13px;
    line-height: 1.2;
}
.teams-chat-item strong .teams-chat-status {
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid #cdd9ea;
    color: #5d718a;
    background: #f6f9ff;
}
.teams-chat-item strong .teams-chat-status.available {
    color: #106b3a;
    border-color: #a6d9ba;
    background: #eaf8f0;
}
.teams-chat-item strong .teams-chat-status.busy,
.teams-chat-item strong .teams-chat-status.donotdisturb {
    color: #8a1f31;
    border-color: #ebc0cb;
    background: #fff0f3;
}
.teams-chat-item strong .teams-chat-status.away,
.teams-chat-item strong .teams-chat-status.berightback {
    color: #915e10;
    border-color: #ecd6a6;
    background: #fff8ea;
}
.teams-chat-item strong .teams-chat-status.offline {
    color: #5d718a;
    border-color: #d4dceb;
    background: #f4f7fc;
}
.teams-chat-item small {
    font-size: 12px;
    color: #5a6d85;
}
.teams-chat-item span {
    font-size: 11px;
    color: #7a8ca5;
}
.teams-chat-item .teams-chat-members {
    font-size: 11px;
    color: #4f6a89;
    line-height: 1.2;
}
.teams-chat-item.active {
    border-color: #2e6fb8;
    background: #eef6ff;
}
.teams-chat-item.unread {
    border-color: #2f72bf;
    background: #f4f9ff;
}
.teams-chat-item.unread small {
    color: #153a62;
    font-weight: 600;
}
.teams-chat-item .teams-chat-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #1f74d0;
    margin-left: 6px;
    vertical-align: middle;
}
.teams-widget-messages {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 0;
}
.teams-widget-chat-head {
    padding: 10px 12px;
    border-bottom: 1px solid #edf2f8;
    font-weight: 700;
    color: #14355a;
}
.teams-message-list {
    overflow: auto;
    padding: 10px 12px;
    background: #f7faff;
    display: grid;
    gap: 8px;
}
.teams-msg {
    border-radius: 10px;
    padding: 8px 10px;
    max-width: 85%;
}
.teams-msg.mine {
    margin-left: auto;
    background: #ddf3ff;
    border: 1px solid #b8e0f4;
}
.teams-msg.other {
    margin-right: auto;
    background: #fff;
    border: 1px solid #d9e3f2;
}
.teams-msg-meta {
    font-size: 11px;
    color: #63778f;
    margin-bottom: 4px;
}
.teams-msg-body {
    font-size: 13px;
    color: #142b46;
    white-space: pre-wrap;
    word-break: break-word;
}
.teams-msg-files {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.teams-msg-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid #cfdcf0;
    background: #f6f9ff;
    color: #1e4f85;
    text-decoration: none;
}
.teams-msg-file:hover {
    border-color: #2f74c4;
}
.teams-send-form {
    border-top: 1px solid #edf2f8;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
    background: #fff;
}
.teams-send-form textarea {
    min-height: 42px;
    resize: vertical;
}

@media (max-width: 1100px) {
    .topbar {
        text-align: left;
    }
    .topbar-main {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
    }
    .topbar-sub {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
    }
    .userbox { text-align: right; margin-left: auto; }
    .cards.two, .cards.three, .grid.two, .grid.three { grid-template-columns: 1fr; }
    .container { margin-top: 8px; padding-top: 8px; }
    .quick-actions { justify-content: center; flex-wrap: wrap; width: 100%; }
    .quick-link { width: auto; max-width: none; text-align: center; }
    .od-toolbar { grid-template-columns: 1fr 1fr; }
    .teams-widget {
        right: 10px;
        left: 10px;
        width: auto;
        height: min(72vh, 640px);
    }
}

@media (max-width: 960px) {
    .menu-toggle-btn { display: inline-flex; }
    .topnav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }
    .topnav.mobile-open { display: flex; }
    .topnav > a,
    .nav-group-toggle { width: 100%; justify-content: space-between; }
    .nav-group { width: 100%; }
    .nav-group-menu {
        position: static;
        border: 1px dashed #cfdaea;
        box-shadow: none;
        margin-top: 6px;
    }
    .nav-group:hover .nav-group-menu { display: none; }
    .nav-group.open .nav-group-menu { display: grid; }

    .login-page {
        justify-content: center;
        align-items: center;
    }
    .login-shell {
        grid-template-columns: 1fr;
        border-radius: 16px;
        min-height: calc(100vh - 24px);
    }
    .login-card { order: 1; }
    .login-brand { order: 2; }
}

@media (max-width: 640px) {
    .topbar {
        padding: 8px 10px 10px;
        gap: 8px;
    }
    .topbar-main {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    .brand {
        justify-content: flex-start;
        gap: 6px;
        min-width: 0;
    }
    .brand img { width: 86px; }
    .userbox {
        text-align: right;
        min-width: 0;
    }
    .userbox strong { font-size: 13px; }
    .userbox small { font-size: 11px; }
    .topbar-sub {
        gap: 6px;
        padding-top: 6px;
        align-items: center;
        flex-wrap: nowrap;
        justify-content: space-between;
    }
    .menu-toggle-btn {
        align-self: auto;
        justify-content: center;
        min-width: 86px;
        padding: 7px 9px;
        font-size: 13px;
        flex: 0 0 auto;
    }
    .quick-actions {
        width: auto;
        min-width: 0;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 6px;
        flex: 1 1 auto;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 2px;
        scrollbar-width: thin;
    }
    .quick-link {
        width: auto;
        flex: 0 0 auto;
        max-width: none;
        padding: 8px 6px;
        font-size: 12px;
        text-align: center;
        line-height: 1.1;
    }
    .quick-link-alert {
        justify-content: center;
    }
    .login-page { padding: 10px; }
    .login-shell { min-height: calc(100vh - 20px); border-radius: 12px; }
    .login-card { padding: 16px; }
    .login-brand { padding: 16px; }
    .brand-logo { width: 84px; height: 84px; }
    .teams-fab {
        right: 12px;
        bottom: 12px;
        padding: 10px 12px;
    }
    .teams-widget {
        right: 0;
        left: 0;
        bottom: 0;
        height: calc(100dvh - 70px);
        border-radius: 14px 14px 0 0;
        border-left: none;
        border-right: none;
    }
    .teams-widget-body {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        height: calc(100% - 48px);
    }
    .teams-widget-chats {
        border-right: none;
        border-bottom: none;
        height: 100%;
    }
    .teams-widget-messages {
        height: 100%;
    }
    .teams-widget:not(.mobile-chat-open) .teams-widget-messages {
        display: none;
    }
    .teams-widget.mobile-chat-open .teams-widget-chats {
        display: none;
    }
    .teams-mobile-back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .teams-widget-search-wrap,
    .teams-widget-newchat {
        padding-left: 8px;
        padding-right: 8px;
    }
    .teams-chat-item {
        padding: 7px 8px;
    }
}

/* TRIAS application shell */
:root {
    --portal-topbar-height: 66px;
    --portal-sidebar-width: 286px;
    --trias-navy: #102a4a;
    --trias-navy-2: #1a365d;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: #f5f7fb;
}

.app-body {
    margin: 0;
    padding-top: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 1200;
    height: var(--portal-topbar-height);
    min-height: var(--portal-topbar-height);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 8px 18px;
    background: var(--trias-navy);
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 6px 18px rgba(16, 42, 74, 0.18);
    margin: 0;
    overflow: visible;
}

.topbar-main {
    width: min(100%, 1800px);
    height: 100%;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
}

.brand,
.brand:hover {
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 12px;
    background: #ffffff;
    border-radius: 8px;
    color: var(--trias-navy);
    flex: 0 0 auto;
}

.brand img {
    width: 124px;
    max-height: 30px;
    object-fit: contain;
    filter: none;
}

.menu-toggle-btn {
    display: inline-flex;
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    box-shadow: none;
}

.menu-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.14);
}

.userbox {
    justify-self: end;
    max-width: 260px;
    color: #ffffff;
    text-align: right;
}

.userbox strong a,
.userbox a {
    color: #ffffff;
}

.userbox small {
    color: rgba(255, 255, 255, 0.72);
}

.userbox small:nth-of-type(2) {
    display: none;
}

.quick-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.quick-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.quick-link:hover,
.quick-link-alert.active {
    border-color: rgba(255, 255, 255, 0.42);
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.quick-link-primary {
    border-color: rgba(255, 255, 255, 0.28);
    background: #ffffff;
    color: var(--trias-navy);
}

.quick-link-primary:hover {
    border-color: #ffffff;
    background: #eef4fb;
    color: var(--trias-navy);
}

.quick-link-badge {
    background: #cf304a;
}

.topbar-sub {
    position: fixed;
    top: var(--portal-topbar-height);
    bottom: 0;
    left: 0;
    z-index: 1100;
    width: var(--portal-sidebar-width);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 12px;
    padding: 16px 14px;
    background: #ffffff;
    border-top: 0;
    border-right: 1px solid var(--line);
    box-shadow: 4px 0 18px rgba(8, 33, 70, 0.06);
    overflow: auto;
    height: calc(100vh - var(--portal-topbar-height));
}

.topnav {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    flex-wrap: nowrap;
}

.topnav > a,
.nav-group-toggle {
    width: 100%;
    min-height: 38px;
    justify-content: space-between;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: #344054;
    font-size: 13px;
    font-weight: 700;
    box-shadow: none;
}

.topnav > a {
    justify-content: flex-start;
    gap: 9px;
}

.nav-group-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.topnav > a > i,
.nav-group-toggle > span > i,
.nav-group-menu a > i {
    width: 18px;
    min-width: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--trias-navy-2);
    font-size: 13px;
    line-height: 1;
    text-align: center;
}

.nav-group-menu a {
    gap: 8px;
}

.nav-group-toggle > .fa-chevron-down {
    width: 14px;
    min-width: 14px;
    color: #8090a4;
}

.topnav > a:hover,
.nav-group-toggle:hover {
    background: #f3f7fb;
    border-color: #dbe4ef;
    color: var(--trias-navy-2);
}

.topnav > a.active,
.nav-group.active > .nav-group-toggle {
    background: #eef5ff;
    border-color: #c7d7e8;
    color: var(--trias-navy-2);
}

.topnav > a.active > i,
.nav-group.active > .nav-group-toggle > span > i,
.nav-group-menu a.active > i {
    color: var(--trias-navy-2);
}

.nav-group {
    width: 100%;
    position: static;
}

.nav-group-toggle i {
    transition: transform 0.18s ease;
}

.nav-group.open > .nav-group-toggle i,
.nav-group.active > .nav-group-toggle i {
    transform: rotate(180deg);
}

.nav-group-menu {
    position: static;
    min-width: 0;
    display: none;
    gap: 4px;
    margin: 6px 0 4px;
    padding: 6px;
    background: #f8fafc;
    border: 1px solid #e5edf5;
    border-radius: 8px;
    box-shadow: none;
}

.nav-group:hover .nav-group-menu {
    display: none;
}

.nav-group.open .nav-group-menu,
.nav-group.active .nav-group-menu {
    display: grid;
}

.nav-group-menu a,
.nav-group-hint {
    display: flex;
    align-items: center;
    min-height: 32px;
    padding: 7px 9px;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    font-size: 12px;
    font-weight: 700;
}

.nav-group-menu a:hover,
.nav-group-menu a.active {
    background: #ffffff;
    color: var(--trias-navy-2);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.nav-group-hint {
    color: #8090a4;
}

.container {
    max-width: none;
    width: auto;
    min-height: calc(100vh - var(--portal-topbar-height));
    margin: 0;
    margin-left: var(--portal-sidebar-width);
    padding: 20px 22px 36px;
}

.pm-active-project-card {
    margin: 0;
}

body.portal-sidebar-collapsed .topbar-sub {
    transform: translateX(calc(-1 * var(--portal-sidebar-width)));
}

body.portal-sidebar-collapsed .container {
    margin-left: 0;
}

.topbar-sub,
.container {
    transition: margin-left 0.2s ease, transform 0.2s ease;
}

@media (max-width: 1100px) {
    .topbar {
        height: auto;
        min-height: var(--portal-topbar-height);
        padding: 8px 14px;
    }

    .topbar-main {
        grid-template-columns: auto auto minmax(0, 1fr);
        grid-template-areas:
            "brand menu user"
            "actions actions actions";
        height: auto;
        row-gap: 8px;
    }

    .brand { grid-area: brand; }
    .menu-toggle-btn { grid-area: menu; }
    .userbox { grid-area: user; }

    .quick-actions {
        grid-area: actions;
        width: auto;
        justify-content: flex-start;
        overflow-x: auto;
    }

    .container {
        margin-top: 0;
        padding-top: 18px;
    }
}

@media (max-width: 960px) {
    :root {
        --portal-sidebar-width: min(86vw, 310px);
    }

    .topbar {
        min-height: 58px;
    }

    .brand img {
        width: 104px;
    }

    .topbar-sub {
        transform: translateX(calc(-1 * var(--portal-sidebar-width)));
        top: 58px;
        height: calc(100vh - 58px);
    }

    .topbar-sub.mobile-open {
        transform: translateX(0);
    }

    body.portal-sidebar-collapsed .topbar-sub {
        transform: translateX(calc(-1 * var(--portal-sidebar-width)));
    }

    .container,
    body.portal-sidebar-collapsed .container {
        margin-left: 0;
        padding: 16px 14px 30px;
    }
}

@media (max-width: 640px) {
    .topbar {
        padding: 8px 10px;
    }

    .userbox {
        max-width: calc(100vw - 172px);
    }

    .quick-actions {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .quick-link {
        flex: 0 0 auto;
    }
}

/* Professional shared controls */
:root {
    --trias-action: #102a4a;
    --trias-action-hover: #1a365d;
    --trias-action-soft: #e8eef6;
    --trias-action-soft-hover: #dfe8f3;
    --trias-green: #2f7d63;
    --trias-green-soft: #e7f4ee;
    --trias-red: #b8485f;
    --trias-red-soft: #f8e8ec;
    --trias-amber: #96713a;
    --trias-amber-soft: #f6efdf;
    --trias-blue-soft: #e8f0fa;
}

body {
    background: var(--bg);
}

.container .btn,
.top-modal .btn,
.modal .btn,
.contact-modal .btn,
.activity-modal .btn,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid #cfd9e6;
    border-radius: 8px;
    padding: 9px 13px;
    background: #ffffff !important;
    background-image: none !important;
    color: var(--trias-action);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    box-shadow: none;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.container .btn:hover,
.top-modal .btn:hover,
.modal .btn:hover,
.contact-modal .btn:hover,
.activity-modal .btn:hover,
.btn:hover {
    background: var(--trias-action-soft) !important;
    border-color: #b8c7d9;
    color: var(--trias-action-hover);
    box-shadow: 0 1px 3px rgba(16, 42, 74, 0.08);
}

.btn.btn-primary,
.container .btn.btn-primary,
.top-modal .btn.btn-primary,
.quick-link-primary {
    background: var(--trias-action) !important;
    background-image: none !important;
    border-color: var(--trias-action);
    color: #ffffff !important;
}

.btn.btn-primary:hover,
.container .btn.btn-primary:hover,
.top-modal .btn.btn-primary:hover,
.quick-link-primary:hover {
    background: var(--trias-action-hover) !important;
    border-color: var(--trias-action-hover);
    color: #ffffff !important;
}

.btn.btn-sm,
.container .btn.btn-sm,
.top-modal .btn.btn-sm {
    min-height: 30px;
    padding: 6px 9px;
    border-radius: 7px;
    font-size: 12px;
}

.btn.danger,
.btn-danger,
.activity-icon-btn.danger,
.ab-icon-btn.danger,
button[style*="background:#cf304a"],
button[style*="background: #cf304a"] {
    background: var(--trias-red-soft) !important;
    background-image: none !important;
    border-color: #e6bcc6 !important;
    color: var(--trias-red) !important;
}

.btn.danger:hover,
.btn-danger:hover,
.activity-icon-btn.danger:hover,
.ab-icon-btn.danger:hover,
button[style*="background:#cf304a"]:hover,
button[style*="background: #cf304a"]:hover {
    background: #f2d7de !important;
    border-color: #dca7b3 !important;
    color: #96374b !important;
}

.btn-success,
.btn.ok,
.alert-ok .btn {
    background: var(--trias-green-soft) !important;
    background-image: none !important;
    border-color: #b9ddcf;
    color: var(--trias-green) !important;
}

.btn-warning,
.btn.warn,
.alert-warning .btn {
    background: var(--trias-amber-soft) !important;
    background-image: none !important;
    border-color: #dfcfa8;
    color: var(--trias-amber) !important;
}

.task-tab-btn,
.task-view-btn,
.activity-icon-btn,
.ab-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    border: 1px solid #cfd9e6 !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    background-image: none !important;
    color: var(--trias-action) !important;
    font-weight: 700;
    box-shadow: none !important;
}

.task-tab-btn:hover,
.task-view-btn:hover,
.activity-icon-btn:hover,
.ab-icon-btn:hover {
    background: var(--trias-action-soft) !important;
    border-color: #b8c7d9 !important;
    color: var(--trias-action-hover) !important;
}

.task-tab-btn.active,
.task-view-btn.active,
.activity-icon-btn.active,
.ab-icon-btn.active {
    background: var(--trias-blue-soft) !important;
    border-color: #b8c7d9 !important;
    color: var(--trias-action-hover) !important;
}

.activity-icon-btn,
.ab-icon-btn {
    width: 34px;
    min-width: 34px;
    padding: 0;
}

.pill,
.tag-chip,
.timeline-pill,
.status-pill,
.admin-status-pill,
.od-type-badge,
.quick-link-badge,
.teams-fab-badge {
    background: var(--trias-blue-soft) !important;
    background-image: none !important;
    border-color: #cbd8e7 !important;
    color: var(--trias-action-hover) !important;
    box-shadow: none !important;
}

.alert-error,
.status-pill.error,
.admin-status-pill.error {
    background: var(--trias-red-soft) !important;
    color: var(--trias-red) !important;
}

.alert-ok,
.status-pill.ok,
.status-pill.sent,
.admin-status-pill.sent {
    background: var(--trias-green-soft) !important;
    color: var(--trias-green) !important;
}

.status-pill.warning,
.admin-status-pill.warning {
    background: var(--trias-amber-soft) !important;
    color: var(--trias-amber) !important;
}

.quick-plus-btn,
.metric-bar > span,
.world-clock-item,
.nav-group.active > .nav-group-toggle {
    background-image: none !important;
}

.quick-plus-btn {
    background: var(--trias-action) !important;
    border: 1px solid var(--trias-action-hover) !important;
}

.metric-bar > span {
    background: var(--trias-green) !important;
}

/* Topbar polish */
.topbar .topbar-main {
    grid-template-columns: auto auto minmax(180px, 1fr) auto;
}

.topbar .quick-actions {
    justify-self: end;
    justify-content: flex-end;
    gap: 8px;
}

.topbar .quick-link,
.topbar .quick-link-primary,
.topbar .quick-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    min-height: 38px;
    min-width: 96px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08) !important;
    background-image: none !important;
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    box-shadow: none !important;
}

.topbar .quick-link:hover,
.topbar .quick-link-primary:hover,
.topbar .quick-link-alert.active,
.topbar .quick-link-icon:hover {
    border-color: rgba(255, 255, 255, 0.46) !important;
    background: rgba(255, 255, 255, 0.16) !important;
    color: #ffffff !important;
}

.topbar .quick-link-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border: 0 !important;
    background: #ffffff !important;
    color: var(--trias-navy) !important;
    font-size: 11px;
}

.topbar .userbox {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    max-width: 360px;
    min-width: 0;
    min-height: 44px;
    padding: 5px 7px 5px 6px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
    text-align: left;
}

.topbar .userbox-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #ffffff;
    color: var(--trias-navy);
    font-size: 13px;
    font-weight: 800;
}

.topbar .userbox-meta {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.topbar .userbox strong {
    display: block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    line-height: 1.15;
}

.topbar .userbox small {
    display: block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.72);
    font-size: 11px;
    line-height: 1.15;
}

.topbar .userbox small:nth-of-type(2) {
    display: none;
}

.topbar .userbox-logout {
    width: 30px;
    height: 30px;
    min-width: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-size: 12px;
}

.topbar .userbox-logout:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

@media (max-width: 1100px) {
    .topbar .topbar-main {
        grid-template-columns: auto auto minmax(0, 1fr);
        grid-template-areas:
            "brand menu user"
            "actions actions actions";
    }

    .topbar .quick-actions {
        grid-area: actions;
        justify-content: flex-start;
    }

    .topbar .userbox {
        grid-area: user;
        max-width: min(360px, 100%);
    }
}

@media (max-width: 640px) {
    .topbar .userbox-avatar,
    .topbar .userbox small {
        display: none;
    }

    .topbar .userbox {
        gap: 6px;
        padding: 5px;
    }

    .topbar .userbox strong {
        max-width: 120px;
    }
}
