        /* ===============================
           Auth / Role-Based UI Lock
           =============================== */
        body.auth-locked {
            overflow: hidden;
        }
        body.auth-locked .app {
            filter: blur(10px);
            pointer-events: none;
            user-select: none;
        }
        .login-overlay {
            position: fixed;
            inset: 0;
            z-index: 2000;
            display: none;
            align-items: center;
            justify-content: center;
            background: rgba(10, 20, 14, 0.55);
            backdrop-filter: blur(10px);
        }
        .login-overlay.active { display: flex; }

        .login-card {
            width: min(520px, 92vw);
            background: #FFFFFF;
            border: 1px solid var(--ph-border);
            border-radius: 18px;
            box-shadow: 0 30px 80px rgba(15,31,22,0.25);
            overflow: hidden;
        }
        .login-card-header {
            display: flex;
            align-items: center;
            gap: 14px;
            padding: 20px 22px;
            border-bottom: 1px solid var(--ph-border);
            background: radial-gradient(900px 260px at 50% -120px, rgba(82,183,136,0.22), transparent 60%),
                        #FFFFFF;
        }

        .login-brand-logo-shell {
            width: 68px;
            height: 68px;
            min-width: 68px;
            border-radius: 18px;
            background: linear-gradient(155deg, rgba(255,255,255,0.98), rgba(232,246,238,0.92));
            border-color: rgba(11,61,46,0.12);
            box-shadow: 0 16px 36px rgba(11,61,46,0.16), inset 0 1px 0 rgba(255,255,255,0.92);
        }
        .login-brand-logo-shell .brand-logo-glow {
            inset: 6px;
        }
        .login-brand-logo-shell .brand-logo-mark {
            width: 48px;
            height: 48px;
        }

        .login-brand {
            display: flex;
            flex-direction: column;
            line-height: 1.1;
        }
        .login-brand .title {
            font-size: 18px;
            font-weight: 700;
            color: var(--ph-text);
            letter-spacing: -0.01em;
        }
        .login-brand .sub {
            margin-top: 4px;
            font-size: 11px;
            letter-spacing: 3px;
            text-transform: uppercase;
            color: var(--ph-text-muted);
        }
        .login-card-body {
            padding: 22px;
        }
        .login-hint {
            font-size: 13px;
            color: var(--ph-text-muted);
            margin-bottom: 14px;
        }
        .login-actions {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            margin-top: 14px;
        }
        .login-error {
            display: none;
            margin-top: 10px;
            padding: 10px 12px;
            border-radius: 10px;
            background: rgba(214,69,69,0.10);
            border: 1px solid rgba(214,69,69,0.22);
            color: var(--danger);
            font-size: 13px;
        }
        .login-error.active { display: block; }

        .user-footer {
            position: sticky;
            bottom: 0;
            z-index: 50;
            padding: 14px 16px 18px;
            border-top: 1px solid var(--ph-border);
            background: #FFFFFF;
        }
        .user-pill {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            background: #FFFFFF;
            border: 1px solid var(--ph-border);
            border-radius: 12px;
            padding: 10px 12px;
        }
        .user-pill .meta {
            display: flex;
            flex-direction: column;
            gap: 2px;
            min-width: 0;
        }
        .user-pill .meta .name {
            font-size: 13px;
            font-weight: 600;
            color: var(--ph-text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .user-pill .meta .role {
            font-size: 11px;
            color: var(--ph-text-muted);
            text-transform: uppercase;
            letter-spacing: 1px;
        }
        .btn-logout {
            padding: 8px 10px;
            border-radius: 10px;
            border: 1px solid var(--ph-border-2);
            background: #FFFFFF;
            cursor: pointer;
            font-size: 12px;
            font-weight: 600;
            color: var(--ph-text);
        }
        .btn-logout:hover {
            border-color: var(--ph-green-main);
            color: var(--ph-green-main);
        }
        .chat-badge {
            position: absolute;
            top: 2px;
            right: 2px;
            background: #1B4332;
            color: white;
            font-size: 10px;
            font-weight: bold;
            padding: 2px 5px;
            border-radius: 10px;
            min-width: 16px;
            text-align: center;
        }
        .chat-panel {
            position: fixed;
            bottom: 80px;
            left: 260px;
            width: 940px;
            height: 560px;
            max-width: calc(100vw - 24px);
            max-height: calc(100vh - 24px);
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 16px;
            box-shadow: 0 18px 55px rgba(0,0,0,0.24);
            display: none;
            flex-direction: column;
            z-index: 1000;
            resize: both;
            overflow: hidden;
            min-width: 640px;
            min-height: 420px;
        }
        .chat-panel.active { display: flex; }
        .chat-panel::after {
            content: '';
            position: absolute;
            bottom: 0;
            right: 0;
            width: 22px;
            height: 22px;
            background: linear-gradient(135deg, transparent 50%, var(--ph-green-main) 50%);
            cursor: nwse-resize;
            border-bottom-right-radius: 16px;
        }
        .chat-header {
            flex: 0 0 auto;
            padding: 12px 16px;
            border-bottom: 1px solid rgba(255,255,255,0.12);
            display: grid;
            grid-template-columns: minmax(0,1fr) auto;
            align-items: center;
            background: linear-gradient(180deg, #1f3a2f 0%, #173126 100%) !important;
            color: white;
            border-radius: 16px 16px 0 0;
            cursor: move;
            user-select: none;
            -webkit-user-select: none;
            touch-action: none;
            gap: 12px;
            min-height: 72px;
            box-shadow: inset 0 -1px 0 rgba(255,255,255,0.06);
            position: relative;
            z-index: 2;
        }
        .chat-header-main {
            min-width: 0;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .chat-header-title-row {
            display: flex;
            align-items: center;
            gap: 10px;
            min-width: 0;
        }
        .chat-header-title {
            font-size: 16px;
            font-weight: 800;
            letter-spacing: .01em;
            color: #fff;
            white-space: nowrap;
        }
        .chat-drag-hint {
            font-size: 12px;
            color: rgba(255,255,255,0.72);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .chat-header h4 { margin: 0; font-size: 14px; }
        .chat-close { 
            background: rgba(255,255,255,0.08); 
            border: 1px solid rgba(255,255,255,0.1); 
            color: white; 
            cursor: pointer; 
            font-size: 24px;
            padding: 8px;
            min-width: 44px;
            min-height: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 12px;
        }
        .chat-body {
            flex: 1 1 auto;
            min-height: 0;
            height: calc(100% - 72px);
            display: grid;
            grid-template-columns: minmax(0, 1fr) 280px;
            background: linear-gradient(180deg, #f7faf8 0%, #eef4f0 100%);
        }
        .chat-main {
            min-width: 0;
            min-height: 0;
            display: flex;
            flex-direction: column;
            border-right: 1px solid var(--border);
            background: linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(246,250,247,0.96) 100%);
        }
        .chat-context-bar {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 10px;
            padding: 12px 16px;
            border-bottom: 1px solid var(--border);
            background: rgba(255,255,255,0.92);
        }
        .chat-context-title {
            font-size: 14px;
            font-weight: 800;
            color: var(--text);
        }
        .chat-context-subtitle {
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 2px;
        }
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
            max-height: none;
            min-height: 200px;
        }
        .chat-msg {
            margin-bottom: 12px;
            padding: 10px 12px;
            border-radius: 12px;
            max-width: min(84%, 620px);
            border: 1px solid var(--border);
            background: #ffffff;
            box-shadow: 0 8px 18px rgba(16,24,40,0.04);
            margin-left: 0;
            margin-right: auto;
        }
        .chat-msg.incoming {
            background: #ffffff;
        }
        .chat-msg.outgoing {
            background: rgba(var(--ph-green-rgb), 0.08);
            border-color: rgba(var(--ph-green-rgb), 0.18);
            color: var(--text);
        }
        .chat-msg .sender {
            font-size: 11px;
            font-weight: 700;
            margin-bottom: 4px;
            color: var(--ph-green-main);
        }
        .chat-msg.outgoing .sender { color: var(--ph-green-dark); }
        .chat-msg .text { font-size: 13px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
        .chat-msg .time {
            font-size: 10px;
            color: var(--text-muted);
            margin-top: 6px;
            text-align: left;
        }
        .chat-sidebar {
            min-width: 0;
            min-height: 0;
            display: flex;
            flex-direction: column;
            background: #f3f7f4;
        }
        .chat-sidebar-head {
            padding: 14px 14px 12px;
            border-bottom: 1px solid var(--border);
            background: rgba(255,255,255,0.7);
        }
        .chat-sidebar-head .title {
            font-size: 12px;
            font-weight: 800;
            letter-spacing: 0.04em;
            text-transform: uppercase;
            color: var(--text-muted);
        }
        .chat-sidebar-head .hint {
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 4px;
        }
        .chat-user-list {
            flex: 1;
            overflow-y: auto;
            padding: 10px;
            display: flex;
            flex-direction: column;
            gap: 8px;
        }
        .chat-user-card {
            width: 100%;
            text-align: left;
            border: 1px solid transparent;
            background: #fff;
            color: var(--text);
            border-radius: 14px;
            padding: 10px 12px;
            cursor: pointer;
            box-shadow: 0 8px 18px rgba(16,24,40,0.04);
            transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
        }
        .chat-user-card:hover {
            transform: translateY(-1px);
            border-color: rgba(var(--ph-green-rgb),0.18);
        }
        .chat-user-card.active {
            background: rgba(var(--ph-green-rgb),0.10);
            border-color: rgba(var(--ph-green-rgb),0.30);
        }
        .chat-user-card-top {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            margin-bottom: 4px;
        }
        .chat-user-name {
            font-size: 13px;
            font-weight: 700;
            color: var(--text);
        }
        .chat-user-role {
            font-size: 11px;
            color: var(--text-muted);
        }
        .chat-user-meta {
            display: flex;
            align-items: center;
            gap: 8px;
            font-size: 11px;
            color: var(--text-muted);
        }
        .chat-user-dot {
            width: 8px;
            height: 8px;
            border-radius: 999px;
            background: #bcc7c1;
            display: inline-block;
        }
        .chat-user-card.online .chat-user-dot {
            background: #2D6A4F;
        }
        .chat-user-empty {
            font-size: 12px;
            color: var(--text-muted);
            padding: 10px 6px;
        }
        .chat-input {
            padding: 12px;
            border-top: 1px solid var(--border);
            display: flex;
            gap: 8px;
            background: rgba(255,255,255,0.92);
        }
        .chat-input input {
            flex: 1;
            padding: 10px 14px;
            border: 1px solid var(--border);
            border-radius: 12px;
            font-size: 13px;
            background: #fff;
        }
        .chat-input button {
            padding: 9px 16px;
            background: var(--ph-green-main);
            color: white;
            border: none;
            border-radius: 12px;
            cursor: pointer;
            font-weight: 700;
        }
        @media (max-width: 980px) {
            .chat-panel {
                left: 14px;
                right: 14px;
                bottom: 14px;
                width: auto;
                min-width: 0;
                height: min(82vh, 620px);
            }
            .chat-body {
                grid-template-columns: minmax(0, 1fr);
            }
            .chat-sidebar {
                display: none;
            }
            .chat-main {
                border-right: 0;
            }
        }
        /* Tablet: slight adjustments only */
        @media (max-width: 1024px) {
            .grid-2 { grid-template-columns: 1fr; }
        }



