:root{
    --app-bg:#eef2f5;
    --surface:#ffffff;
    --surface-soft:#f7f9fa;
    --line:#e6eaed;
    --text:#182229;
    --muted:#667781;
    --muted-2:#8696a0;
    --green:#00a884;
    --green-dark:#008069;
    --green-soft:#e7f8f3;
    --chat-bg:#efeae2;
    --bubble-in:#ffffff;
    --bubble-out:#d9fdd3;
    --danger:#d92d20;
    --shadow:0 18px 50px rgba(24,34,41,.12);
    --shadow-soft:0 1px 3px rgba(24,34,41,.08);
}

.login-page{
    min-height:100vh;
    background:
        radial-gradient(circle at 16% 18%, rgba(0,168,132,.16), transparent 28%),
        linear-gradient(135deg, #f7f9fa 0%, #eef2f5 48%, #e7f8f3 100%);
}

.login-shell{
    min-height:100vh;
    display:grid;
    grid-template-columns:minmax(0, 1.1fr) 420px;
    align-items:center;
    gap:44px;
    width:min(1120px, calc(100% - 40px));
    margin:0 auto;
    padding:48px 0;
}

.login-welcome{
    padding:36px;
}

.login-brand{
    display:inline-flex;
    align-items:center;
    gap:10px;
    min-height:42px;
    padding:0 14px;
    border:1px solid rgba(0,168,132,.18);
    border-radius:999px;
    background:#ffffff;
    color:var(--green-dark);
    font-weight:800;
    box-shadow:var(--shadow-soft);
}

.login-brand i{
    color:var(--green);
    font-size:20px;
}

.login-welcome h1{
    margin:24px 0 12px;
    color:var(--text);
    font-size:38px;
    line-height:1.35;
    font-weight:900;
    letter-spacing:0;
}

.login-welcome p{
    max-width:560px;
    margin:0;
    color:var(--muted);
    font-size:16px;
    line-height:1.9;
}

.login-whatsapp-link{
    display:inline-flex;
    align-items:center;
    gap:9px;
    margin-top:22px;
    min-height:46px;
    padding:0 16px;
    border-radius:999px;
    background:var(--green);
    color:#ffffff;
    text-decoration:none;
    font-weight:900;
    box-shadow:0 10px 22px rgba(0,128,105,.2);
}

.login-whatsapp-link:hover{
    background:var(--green-dark);
    color:#ffffff;
}

.login-features{
    display:flex;
    flex-wrap:wrap;
    gap:10px;
    margin-top:26px;
}

.login-features div{
    display:flex;
    align-items:center;
    gap:8px;
    padding:10px 12px;
    border:1px solid var(--line);
    border-radius:10px;
    background:rgba(255,255,255,.86);
    color:var(--text);
    box-shadow:var(--shadow-soft);
}

.login-features i{
    color:var(--green);
}

.login-card{
    background:#ffffff;
    border:1px solid var(--line);
    border-radius:18px;
    padding:28px;
    box-shadow:var(--shadow);
}

.login-card-header{
    margin-bottom:22px;
}

.login-card-header h2{
    margin:0;
    color:var(--text);
    font-size:24px;
    font-weight:900;
}

.login-card-header p{
    margin:7px 0 0;
    color:var(--muted);
}

.login-label{
    display:block;
    margin:14px 0 7px;
    color:var(--text);
    font-weight:800;
    font-size:13px;
}

.login-input{
    width:100%;
    height:46px;
    border:1px solid var(--line);
    border-radius:10px;
    background:var(--surface-soft);
    color:var(--text);
    padding:0 13px;
    outline:none;
    transition:border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.login-input:focus{
    border-color:rgba(0,168,132,.55);
    background:#ffffff;
    box-shadow:0 0 0 4px rgba(0,168,132,.08);
}

.login-button{
    width:100%;
    height:48px;
    margin-top:22px;
    border:0;
    border-radius:10px;
    background:var(--green);
    color:#ffffff;
    font-weight:900;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    cursor:pointer;
    box-shadow:0 10px 22px rgba(0,128,105,.2);
}

.login-button:hover{
    background:var(--green-dark);
}

*{
    box-sizing:border-box;
}

html,
body{
    height:100%;
}

body{
    margin:0;
    background:var(--app-bg);
    color:var(--text);
    font-family:Tahoma, Arial, sans-serif;
    font-size:14px;
}

.app{
    display:flex;
    width:100vw;
    max-width:100vw;
    height:100vh;
    overflow:hidden;
    background:var(--surface);
}

.sidebar{
    width:400px;
    min-width:320px;
    max-width:400px;
    flex:0 0 400px;
    background:var(--surface);
    border-left:1px solid var(--line);
    display:flex;
    flex-direction:column;
    z-index:2;
}

.sidebar-header{
    min-height:86px;
    padding:18px 20px 14px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    border-bottom:1px solid var(--line);
    background:var(--surface);
}

.sidebar-header h1{
    margin:0;
    color:var(--text);
    font-size:21px;
    font-weight:800;
    letter-spacing:0;
}

.sidebar-header h1 i{
    color:var(--green);
    margin-left:8px;
}

.sidebar-header p{
    margin:5px 0 0;
    color:var(--muted);
    font-size:13px;
}

.logout-link{
    width:38px;
    height:38px;
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--muted);
    text-decoration:none;
    border:1px solid var(--line);
    border-radius:8px;
    background:var(--surface-soft);
}

.sidebar-actions{
    display:flex;
    gap:8px;
}

button.logout-link{
    cursor:pointer;
}

.logout-link:hover{
    color:var(--danger);
    background:#fff4f2;
    border-color:#ffd4cc;
}

.search-box{
    position:relative;
    padding:14px 16px;
    background:var(--surface);
    border-bottom:1px solid var(--line);
}

.search-box i{
    position:absolute;
    top:27px;
    right:30px;
    color:var(--muted-2);
    font-size:14px;
}

.search-box input{
    width:100%;
    height:42px;
    border:1px solid var(--line);
    border-radius:10px;
    background:var(--surface-soft);
    color:var(--text);
    padding:0 40px 0 14px;
    outline:none;
    transition:border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.search-box input:focus{
    border-color:rgba(0,168,132,.55);
    background:#ffffff;
    box-shadow:0 0 0 4px rgba(0,168,132,.08);
}

.conversation-list{
    flex:1;
    overflow:auto;
    padding:8px;
}

.conversation{
    position:relative;
    display:flex;
    gap:12px;
    align-items:center;
    min-height:74px;
    padding:12px;
    color:var(--text);
    cursor:pointer;
    border-radius:10px;
    border:1px solid transparent;
    transition:background .15s ease, border-color .15s ease, transform .15s ease;
}

.conversation:hover{
    background:var(--surface-soft);
}

.conversation.active{
    background:var(--green-soft);
    border-color:rgba(0,168,132,.18);
}

.conversation-avatar,
.avatar{
    width:44px;
    height:44px;
    border-radius:50%;
    background:#dfe5e7;
    color:#54656f;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
    flex:0 0 auto;
    overflow:hidden;
}

.conversation.active .conversation-avatar{
    background:var(--green);
    color:#ffffff;
}

.conversation-body{
    min-width:0;
    flex:1;
}

.conversation-top{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:10px;
    min-width:0;
}

.phone{
    min-width:0;
    margin-bottom:5px;
    overflow:hidden;
    color:var(--text);
    font-size:14.5px;
    font-weight:800;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.conversation-time{
    flex:0 0 auto;
    color:var(--muted-2);
    font-size:11px;
}

.last{
    color:var(--muted);
    font-size:13px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.badge{
    min-width:22px;
    flex:0 0 auto;
    padding:4px 7px;
    border-radius:999px;
    background:var(--green);
    color:#ffffff;
    font-size:11px;
    font-weight:800;
    text-align:center;
}

.chat-area{
    flex:1;
    width:calc(100vw - 400px);
    min-width:0;
    display:flex;
    flex-direction:column;
    background:var(--chat-bg);
}

.chat-header{
    min-height:74px;
    padding:12px 20px;
    background:rgba(255,255,255,.96);
    border-bottom:1px solid var(--line);
    display:flex;
    align-items:center;
    gap:12px;
    box-shadow:var(--shadow-soft);
    z-index:1;
}

.avatar{
    background:var(--green);
    color:#ffffff;
}

.chat-heading{
    min-width:0;
    flex:1;
}

.chat-title{
    color:var(--text);
    font-size:16px;
    font-weight:800;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.chat-subtitle{
    margin-top:3px;
    color:var(--muted);
    font-size:13px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.icon-text-button{
    height:38px;
    border:1px solid var(--line);
    border-radius:9px;
    background:#ffffff;
    color:var(--text);
    padding:0 12px;
    cursor:pointer;
    display:flex;
    align-items:center;
    gap:7px;
    flex:0 0 auto;
    transition:background .15s ease, border-color .15s ease, color .15s ease;
}

.icon-text-button:disabled{
    opacity:.45;
    cursor:not-allowed;
}

.icon-text-button:not(:disabled):hover,
.icon-text-button.ready{
    color:var(--green-dark);
    border-color:rgba(0,168,132,.38);
    background:var(--green-soft);
}

#messages{
    flex:1;
    min-width:0;
    overflow:auto;
    padding:28px;
    background-color:var(--chat-bg);
    background-image:
        linear-gradient(rgba(239,234,226,.92), rgba(239,234,226,.92)),
        repeating-linear-gradient(135deg, rgba(255,255,255,.22) 0 1px, transparent 1px 18px);
}

.msg{
    position:relative;
    width:fit-content;
    max-width:min(68%, 680px);
    margin-bottom:12px;
    padding:10px 13px 21px;
    border-radius:12px;
    color:var(--text);
    line-height:1.65;
    word-wrap:break-word;
    overflow-wrap:anywhere;
    white-space:pre-wrap;
    box-shadow:0 1px 2px rgba(24,34,41,.14);
}

.msg.in{
    background:var(--bubble-in);
    border-top-right-radius:4px;
}

.msg.out{
    background:var(--bubble-out);
    margin-right:auto;
    border-top-left-radius:4px;
}

.msg-time{
    position:absolute;
    left:10px;
    bottom:4px;
    color:#667781;
    font-size:11px;
}

.msg-sender{
    margin-bottom:4px;
    color:var(--green-dark);
    font-size:12px;
    font-weight:900;
}

.msg-media-link{
    display:block;
    width:240px;
    max-width:100%;
    max-height:240px;
    overflow:hidden;
    border-radius:10px;
    margin-bottom:8px;
    background:#f0f2f5;
}

.msg-media{
    display:block;
    width:100%;
    height:100%;
    max-height:240px;
    object-fit:cover;
    border-radius:10px;
}

.msg-audio{
    display:block;
    width:280px;
    max-width:100%;
    height:42px;
    margin-bottom:6px;
}

.msg-video{
    display:block;
    width:300px;
    max-width:100%;
    max-height:420px;
    object-fit:contain;
    border-radius:10px;
    margin-bottom:8px;
}

.msg-file{
    display:inline-block;
    color:var(--green-dark);
    font-weight:800;
    text-decoration:none;
    margin-bottom:8px;
}

.send-box{
    display:flex;
    gap:12px;
    padding:14px 18px;
    background:rgba(247,249,250,.98);
    border-top:1px solid var(--line);
}

.send-box input{
    flex:1;
    min-width:0;
    height:46px;
    border:1px solid var(--line);
    border-radius:999px;
    background:#ffffff;
    color:var(--text);
    padding:0 18px;
    outline:none;
    box-shadow:var(--shadow-soft);
}

.send-box input:focus{
    border-color:rgba(0,168,132,.55);
    box-shadow:0 0 0 4px rgba(0,168,132,.08);
}

.send-box button{
    width:46px;
    min-width:46px;
    height:46px;
    border:0;
    border-radius:50%;
    background:var(--green);
    color:#ffffff;
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:17px;
    box-shadow:0 8px 18px rgba(0,128,105,.22);
}

.send-box button:hover{
    background:var(--green-dark);
}

.send-box button:disabled{
    opacity:.65;
    cursor:wait;
}

.empty-state{
    height:100%;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    color:var(--muted);
    text-align:center;
}

.empty-state h2{
    margin:16px 0 6px;
    color:var(--text);
    font-size:22px;
    font-weight:800;
}

.empty-state p{
    margin:0;
    font-size:14px;
}

.empty-icon{
    width:76px;
    height:76px;
    border-radius:20px;
    background:#ffffff;
    border:1px solid var(--line);
    display:flex;
    align-items:center;
    justify-content:center;
    color:var(--green);
    font-weight:800;
    box-shadow:var(--shadow-soft);
}

.name-modal{
    position:fixed;
    inset:0;
    z-index:50;
    display:none;
    align-items:center;
    justify-content:center;
    background:rgba(24,34,41,.42);
    padding:20px;
}

.name-modal.open{
    display:flex;
}

.name-modal-panel{
    width:380px;
    max-width:100%;
    background:#ffffff;
    border-radius:12px;
    padding:22px;
    box-shadow:var(--shadow);
}

.name-modal-panel h3{
    margin:0 0 8px;
    color:var(--text);
    font-size:18px;
    font-weight:800;
}

.name-modal-panel p{
    margin:0 0 14px;
    color:var(--muted);
    font-size:13px;
}

.name-modal-panel input{
    width:100%;
    height:44px;
    border:1px solid var(--line);
    border-radius:9px;
    padding:0 12px;
    outline:none;
}

.wide-modal{
    width:460px;
}

.modal-label{
    display:block;
    margin:12px 0 6px;
    color:var(--muted);
    font-size:12px;
    font-weight:800;
}

.name-modal-panel textarea{
    width:100%;
    border:1px solid var(--line);
    border-radius:9px;
    padding:10px 12px;
    outline:none;
    resize:vertical;
    direction:ltr;
    text-align:left;
    font-family:Menlo, Consolas, monospace;
}

.name-modal-panel textarea:focus{
    border-color:rgba(0,168,132,.55);
    box-shadow:0 0 0 4px rgba(0,168,132,.08);
}

.name-modal-panel input:focus{
    border-color:rgba(0,168,132,.55);
    box-shadow:0 0 0 4px rgba(0,168,132,.08);
}

.name-modal-actions{
    display:flex;
    justify-content:flex-start;
    gap:10px;
    margin-top:16px;
}

.primary-button,
.secondary-button{
    height:40px;
    border-radius:9px;
    padding:0 16px;
    cursor:pointer;
}

.primary-button{
    border:0;
    background:var(--green);
    color:#ffffff;
}

.secondary-button{
    border:1px solid var(--line);
    background:#ffffff;
    color:var(--text);
}

.toast-message{
    position:fixed;
    right:50%;
    bottom:84px;
    z-index:80;
    transform:translateX(50%) translateY(14px);
    max-width:420px;
    background:var(--text);
    color:#ffffff;
    border-radius:10px;
    padding:11px 16px;
    opacity:0;
    pointer-events:none;
    box-shadow:var(--shadow);
    transition:opacity .18s ease, transform .18s ease;
}

.toast-message.show{
    opacity:1;
    transform:translateX(50%) translateY(0);
}

.users-page{
    min-height:100vh;
    background:var(--app-bg);
}

.users-shell{
    width:min(1050px, calc(100% - 32px));
    margin:0 auto;
    padding:36px 0;
}

.users-header{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    margin-bottom:20px;
}

.users-header h1{
    margin:0;
    color:var(--text);
    font-size:28px;
    font-weight:900;
}

.users-header p{
    margin:6px 0 0;
    color:var(--muted);
}

.users-grid{
    display:grid;
    grid-template-columns:390px minmax(0, 1fr);
    gap:18px;
    align-items:start;
}

.users-card{
    background:#ffffff;
    border:1px solid var(--line);
    border-radius:16px;
    padding:22px;
    box-shadow:var(--shadow-soft);
}

.users-card h2{
    margin:0 0 16px;
    font-size:19px;
    font-weight:900;
}

.users-list{
    display:grid;
    gap:10px;
}

.user-row{
    display:flex;
    align-items:center;
    gap:12px;
    padding:12px;
    border:1px solid var(--line);
    border-radius:12px;
    background:var(--surface-soft);
}

.user-avatar{
    width:42px;
    height:42px;
    border-radius:50%;
    background:var(--green-soft);
    color:var(--green-dark);
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:900;
}

.user-row strong,
.user-row span{
    display:block;
}

.user-row span{
    color:var(--muted);
    font-size:12px;
}

.users-back{
    text-decoration:none;
    display:inline-flex;
    align-items:center;
    gap:8px;
}

.password-card{
    grid-column:1 / -1;
}

.single-users-grid{
    display:block;
}

.single-users-grid .password-card{
    max-width:460px;
}

.password-button{
    max-width:260px;
}

@media (max-width:760px){
    .app{
        flex-direction:column;
    }

    .sidebar{
        width:100%;
        max-width:none;
        flex:0 0 auto;
        min-height:250px;
        max-height:42vh;
        border-left:0;
        border-bottom:1px solid var(--line);
    }

    .chat-area{
        width:100%;
    }

    .chat-header{
        min-height:66px;
        padding:10px 14px;
    }

    #messages{
        padding:16px;
    }

    .msg{
        max-width:88%;
    }

    .icon-text-button span{
        display:none;
    }

    .users-header,
    .users-grid{
        display:block;
    }

    .users-back{
        margin-top:14px;
    }

    .users-card{
        margin-bottom:16px;
    }
}
