:root{
    --app-bg:#f5f5f2;
    --surface:#ffffff;
    --surface-soft:#f7f7f4;
    --line:#e5e5df;
    --text:#1d1a14;
    --muted:#62605a;
    --muted-2:#8a877f;
    --green:#10805f;
    --green-dark:#0d4e40;
    --green-soft:#e8f3ee;
    --accent:#d86e5f;
    --accent-soft:#fff0ec;
    --chat-bg:#efeee8;
    --bubble-in:#ffffff;
    --bubble-out:#e7f5ed;
    --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:linear-gradient(135deg, #ffffff 0%, #f5f5f2 58%, #ededE7 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;
    width:132px;
    height:132px;
    padding:10px;
    border:1px solid rgba(17,16,12,.12);
    border-radius:50%;
    background:#ffffff;
    color:var(--green-dark);
    font-weight:800;
    box-shadow:var(--shadow-soft);
}

.brand-wordmark{
    width:100%;
    height:100%;
    object-fit:cover;
    border-radius:50%;
    display:block;
}

.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(17,16,12,.18);
}

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

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

.login-features a{
    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);
    text-decoration:none;
    font-weight:800;
    box-shadow:var(--shadow-soft);
}

.login-features a:hover{
    border-color:rgba(16,128,95,.28);
    background:var(--green-soft);
    color:var(--green-dark);
}

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

.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(17,16,12,.42);
    background:#ffffff;
    box-shadow:0 0 0 4px rgba(17,16,12,.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(17,16,12,.18);
}

.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:162px;
    padding:16px 20px 14px;
    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:12px;
    border-bottom:1px solid var(--line);
    background:var(--surface);
}

.sidebar-brand{
    min-width:0;
    display:flex;
    justify-content:center;
    align-items:center;
    width:100%;
}

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

.sidebar-wordmark{
    width:106px;
    height:106px;
    object-fit:cover;
    border-radius:50%;
    display:block;
}

.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;
    justify-content:center;
    flex-wrap:wrap;
    gap:8px;
}

button.logout-link{
    cursor:pointer;
}

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

.logout-link.push-enabled{
    color:var(--green-dark);
    background:var(--green-soft);
    border-color:rgba(16,128,95,.26);
}

.logout-link.push-pending{
    opacity:.72;
    pointer-events:none;
}

.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(17,16,12,.42);
    background:#ffffff;
    box-shadow:0 0 0 4px rgba(17,16,12,.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(17,16,12,.12);
}

.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-avatar img,
.avatar img,
.customer-image-preview img{
    display:block;
    width:100%;
    height:100%;
    object-fit:cover;
}

.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(17,16,12,.28);
    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);
    min-width:0;
    margin-bottom:12px;
    padding:10px 13px 21px;
    border-radius:12px;
    color:var(--text);
    line-height:1.65;
    word-wrap:break-word;
    overflow-wrap:anywhere;
    box-shadow:0 1px 2px rgba(24,34,41,.14);
}

.msg-text{
    max-width:100%;
    min-width:0;
    white-space:pre-wrap;
    overflow-wrap:anywhere;
    word-break:break-word;
    direction:rtl;
    text-align:right;
    unicode-bidi:plaintext;
}

.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;
}

.msg-media-fallback{
    font-size:12px;
}

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

.send-box[hidden]{
    display:none;
}

.composer-main{
    flex:1;
    min-width:0;
    display:flex;
    flex-direction:column;
    gap:8px;
}

.send-box #messageInput{
    width:100%;
    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 #messageInput:focus{
    border-color:rgba(17,16,12,.42);
    box-shadow:0 0 0 4px rgba(17,16,12,.08);
}

.send-box #sendButton{
    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(17,16,12,.18);
}

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

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

.composer-action-button{
    width:42px;
    min-width:42px;
    height:42px;
    margin-bottom:2px;
    border:1px solid var(--line);
    border-radius:50%;
    background:#ffffff;
    color:var(--muted);
    cursor:pointer;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:17px;
    box-shadow:var(--shadow-soft);
}

.composer-action-button:hover{
    color:var(--green-dark);
    border-color:rgba(17,16,12,.28);
    background:var(--green-soft);
}

.composer-action-button.recording{
    color:#ffffff;
    border-color:var(--accent);
    background:var(--accent);
}

.media-preview{
    display:flex;
    align-items:center;
    gap:10px;
    max-width:100%;
    min-height:58px;
    padding:8px;
    border:1px solid var(--line);
    border-radius:10px;
    background:#ffffff;
    box-shadow:var(--shadow-soft);
}

.media-preview[hidden]{
    display:none;
}

.media-preview-thumb{
    width:58px;
    height:58px;
    flex:0 0 58px;
    border-radius:8px;
    object-fit:cover;
    background:#f0f2f5;
}

.media-preview-audio{
    width:220px;
    max-width:42vw;
    height:40px;
}

.media-preview-file-icon{
    width:42px;
    height:42px;
    flex:0 0 42px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:8px;
    background:var(--surface-soft);
    color:var(--green-dark);
    font-size:22px;
}

.media-preview-info{
    min-width:0;
    flex:1;
    display:flex;
    flex-direction:column;
    gap:2px;
}

.media-preview-info strong,
.media-preview-info span{
    display:block;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.media-preview-info strong{
    color:var(--text);
    font-size:13px;
}

.media-preview-info span{
    color:var(--muted);
    font-size:12px;
}

.media-preview-remove{
    width:32px;
    min-width:32px;
    height:32px;
    border:0;
    border-radius:50%;
    background:var(--surface-soft);
    color:var(--muted);
    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
}

.media-preview-remove:hover{
    color:var(--danger);
    background:#fff4f2;
}

.reactivation-box{
    display:grid;
    grid-template-columns:minmax(180px, 1.1fr) minmax(170px, .9fr) minmax(190px, 1fr) auto;
    align-items:center;
    gap:10px;
    padding:12px 18px;
    background:#fff8f0;
    border-top:1px solid #f3d5b8;
}

.reactivation-box[hidden]{
    display:none;
}

.reactivation-copy strong,
.reactivation-copy span{
    display:block;
}

.reactivation-copy strong{
    color:var(--text);
    font-weight:900;
}

.reactivation-copy span{
    margin-top:3px;
    color:var(--muted);
    font-size:12px;
}

.reactivation-box select,
.reactivation-box textarea{
    width:100%;
    min-height:42px;
    border:1px solid var(--line);
    border-radius:9px;
    background:#ffffff;
    padding:8px 10px;
    outline:none;
}

.reactivation-box textarea{
    resize:vertical;
    direction:ltr;
    text-align:left;
    font-family:Menlo, Consolas, monospace;
}

.reactivation-box .form-hint{
    grid-column:2 / 4;
    margin:0;
}

.reactivation-box button{
    height:42px;
    border:0;
    border-radius:9px;
    background:var(--green);
    color:#ffffff;
    padding:0 14px;
    font-weight:900;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    cursor:pointer;
}

.reactivation-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;
    font-size:15px;
    box-shadow:var(--shadow-soft);
}

.empty-icon img{
    width:54px;
    height:54px;
    display:block;
    border-radius:16px;
}

.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,
.name-modal-panel select{
    width:100%;
    height:44px;
    border:1px solid var(--line);
    border-radius:9px;
    padding:0 12px;
    outline:none;
}

.customer-image-editor{
    display:flex;
    align-items:center;
    gap:12px;
    margin:12px 0 16px;
    padding:12px;
    border:1px solid var(--line);
    border-radius:10px;
    background:var(--surface-soft);
}

.customer-image-preview{
    width:58px;
    height:58px;
    flex:0 0 58px;
    border-radius:50%;
    overflow:hidden;
    display:flex;
    align-items:center;
    justify-content:center;
    background:var(--green);
    color:#ffffff;
    font-weight:900;
}

.customer-image-actions{
    min-width:0;
    display:flex;
    flex-wrap:wrap;
    gap:8px;
}

.image-upload-button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
    margin:0;
}

.customer-image-actions .secondary-button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:7px;
}

.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(17,16,12,.42);
    box-shadow:0 0 0 4px rgba(17,16,12,.08);
}

.name-modal-panel input:focus,
.name-modal-panel select:focus{
    border-color:rgba(17,16,12,.42);
    box-shadow:0 0 0 4px rgba(17,16,12,.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);
}

.header-actions{
    display:flex;
    align-items:center;
    justify-content:flex-start;
    gap:10px;
    flex-wrap:wrap;
}

.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;
}

.customers-shell{
    width:min(1240px, calc(100% - 32px));
}

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

.broadcast-card{
    position:sticky;
    top:24px;
}

.customers-card{
    min-width:0;
}

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

.customers-card-header h2{
    margin-bottom:4px;
}

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

.customers-header-actions{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap:10px;
    flex-wrap:wrap;
}

.customer-sync-form{
    margin:0;
}

.customer-import-panel{
    margin-top:22px;
    padding-top:18px;
    border-top:1px solid var(--line);
}

.customer-import-panel h2{
    margin-bottom:12px;
}

.customer-import-button{
    width:100%;
    justify-content:center;
    margin-top:12px;
}

.customer-import-summary{
    display:flex;
    align-items:center;
    gap:10px 16px;
    flex-wrap:wrap;
}

.customer-import-summary strong,
.customer-import-summary small{
    width:100%;
}

.customers-filter{
    display:grid;
    grid-template-columns:180px 240px auto;
    gap:10px;
    align-items:center;
}

.customers-table-wrap{
    overflow:auto;
    border:1px solid var(--line);
    border-radius:12px;
}

.customers-table{
    width:100%;
    min-width:900px;
    border-collapse:collapse;
    background:#ffffff;
}

.customers-table th,
.customers-table td{
    padding:13px 14px;
    border-bottom:1px solid var(--line);
    vertical-align:middle;
    text-align:right;
}

.customers-table th{
    background:var(--surface-soft);
    color:var(--muted);
    font-size:12px;
    font-weight:900;
}

.customers-table tr:last-child td{
    border-bottom:0;
}

.customers-table strong,
.customers-table span{
    display:block;
}

.customers-table span{
    max-width:300px;
    color:var(--muted);
    font-size:12px;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}

.customers-empty{
    color:var(--muted);
    text-align:center !important;
    padding:28px 14px !important;
}

.ltr-input,
.ltr-cell{
    direction:ltr;
    text-align:left;
}

.customer-textarea{
    width:100%;
    border:1px solid var(--line);
    border-radius:10px;
    padding:10px 12px;
    resize:vertical;
    outline:none;
}

.customer-textarea:focus{
    border-color:rgba(17,16,12,.42);
    box-shadow:0 0 0 4px rgba(17,16,12,.08);
}

.form-hint{
    margin:7px 0 0;
    color:var(--muted);
    font-size:12px;
    line-height:1.7;
}

.hidden-fields{
    display:none;
}

.alert-message{
    border-radius:10px;
    padding:12px 14px;
    margin-bottom:14px;
    font-weight:800;
}

.error-message{
    background:#fff1f1;
    color:#9f1d1d;
    border:1px solid #ffd2d2;
}

.sync-result-grid{
    display:grid;
    grid-template-columns:repeat(4, minmax(0, 1fr));
    gap:12px;
}

.sync-result-grid div{
    border:1px solid var(--line);
    background:var(--surface-soft);
    border-radius:10px;
    padding:14px;
}

.sync-result-grid strong,
.sync-result-grid span{
    display:block;
}

.sync-result-grid strong{
    font-size:28px;
    line-height:1;
    margin-bottom:8px;
}

.sync-result-grid span{
    color:var(--muted);
    font-size:12px;
    line-height:1.7;
}

.mini-button{
    min-width:64px;
    height:34px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    text-decoration:none;
    white-space:nowrap;
}

.template-tools-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:18px;
    align-items:start;
    margin-bottom:18px;
}

.template-list-card{
    margin-top:0;
}

.campaigns-shell{
    width:min(1320px, calc(100% - 32px));
}

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

.campaign-create-card{
    position:sticky;
    top:24px;
}

.campaigns-main{
    display:grid;
    gap:18px;
    min-width:0;
}

.inline-action-form{
    margin:0;
}

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

.campaign-detail-header h2{
    margin-bottom:4px;
}

.campaign-detail-header p{
    margin:0;
    color:var(--muted);
}

.campaign-stat-grid{
    display:grid;
    grid-template-columns:repeat(5, minmax(0, 1fr));
    gap:10px;
    margin-bottom:14px;
}

.campaign-stat-grid div{
    border:1px solid var(--line);
    border-radius:10px;
    background:var(--surface-soft);
    padding:12px;
}

.campaign-stat-grid strong,
.campaign-stat-grid span{
    display:block;
}

.campaign-stat-grid strong{
    color:var(--text);
    font-size:24px;
    line-height:1;
    margin-bottom:6px;
}

.campaign-stat-grid span{
    color:var(--muted);
    font-size:12px;
    font-weight:800;
}

.campaign-run-form{
    margin:0 0 14px;
}

.campaign-status{
    display:inline-flex !important;
    align-items:center;
    justify-content:center;
    min-height:26px;
    padding:4px 9px;
    border-radius:999px;
    font-size:12px !important;
    font-weight:900;
    white-space:nowrap;
}

.campaign-status-queued,
.campaign-status-pending{
    color:#855a00 !important;
    background:#fff4cf;
}

.campaign-status-sending{
    color:#055160 !important;
    background:#cff4fc;
}

.campaign-status-completed,
.campaign-status-sent{
    color:#0f5132 !important;
    background:#d1e7dd;
}

.campaign-status-failed{
    color:#842029 !important;
    background:#f8d7da;
}

.campaign-status-skipped,
.campaign-status-paused{
    color:#41464b !important;
    background:#e2e3e5;
}

.campaign-recipients-table{
    min-width:980px;
}

.campaigns-table{
    min-width:980px;
}

.import-template-card{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
    margin-bottom:18px;
}

.import-template-card h2{
    margin-bottom:4px;
}

.import-template-card p{
    margin:0;
    color:var(--muted);
}

.import-template-button{
    width:auto;
    min-width:190px;
    margin-top:0;
}

.template-media-library{
    margin-bottom:18px;
}

.template-upload-form{
    display:grid;
    grid-template-columns:minmax(220px, 1fr) auto;
    gap:10px;
    align-items:center;
    max-width:520px;
}

.media-library-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(118px, 1fr));
    gap:12px;
}

.media-library-item{
    border:1px solid var(--line);
    border-radius:12px;
    background:var(--surface-soft);
    padding:8px;
}

.media-library-item img{
    width:100%;
    aspect-ratio:1 / 1;
    object-fit:cover;
    border-radius:9px;
    background:#ffffff;
    display:block;
    margin-bottom:8px;
}

.media-library-item .mini-button{
    width:100%;
}

.template-preview-card{
    margin-top:16px;
    border:1px solid var(--line);
    border-radius:12px;
    background:var(--chat-bg);
    padding:12px;
    box-shadow:var(--shadow-soft);
}

.compact-preview{
    min-width:220px;
    max-width:280px;
}

.preview-label{
    color:var(--muted);
    font-size:12px;
    font-weight:900;
    margin-bottom:8px;
}

.preview-image{
    width:100%;
    max-height:180px;
    object-fit:cover;
    border-radius:10px;
    background:#ffffff;
    display:none;
    margin-bottom:10px;
}

.preview-title{
    display:none;
    color:var(--text);
    font-weight:900;
    margin-bottom:6px;
}

.preview-body{
    background:var(--bubble-out);
    color:var(--text);
    border-radius:12px 12px 3px 12px;
    padding:10px 12px;
    line-height:1.8;
    white-space:pre-wrap;
}

.preview-button{
    display:none;
    align-items:center;
    justify-content:center;
    min-height:36px;
    margin-top:8px;
    padding:0 12px;
    border-radius:9px;
    border:1px solid rgba(0,128,105,.2);
    background:#ffffff;
    color:var(--green-dark);
    font-weight:900;
}

.inline-template-form,
.inline-variables-form{
    display:grid;
    gap:8px;
}

.inline-template-form{
    grid-template-columns:minmax(220px, 1fr) auto;
    align-items:center;
}

.compact-textarea{
    min-width:220px;
    min-height:78px;
    font-size:12px;
}

.editable-templates-table{
    min-width:980px;
}

.template-index-table{
    min-width:860px;
}

.template-index-table td:first-child strong{
    display:block;
    color:var(--text);
    font-size:15px;
    margin-bottom:5px;
}

.template-index-table td:first-child span{
    display:block;
    color:var(--muted);
    font-size:12px;
}

.template-list-preview{
    display:-webkit-box;
    max-width:520px;
    color:var(--text);
    line-height:1.7;
    overflow:hidden;
    -webkit-line-clamp:2;
    -webkit-box-orient:vertical;
}

.template-feature-tags{
    display:flex;
    flex-wrap:wrap;
    gap:6px;
}

.template-feature-tags span{
    display:inline-flex;
    align-items:center;
    gap:5px;
    min-height:28px;
    padding:0 10px;
    border-radius:999px;
    background:#e7f6f0;
    color:var(--green-dark);
    font-size:12px;
    font-weight:900;
}

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

.template-editor-main{
    display:grid;
    gap:18px;
    min-width:0;
}

.template-editor-card{
    display:grid;
    gap:12px;
}

.template-two-columns{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
}

.template-editor-body{
    min-height:170px;
}

.template-editor-actions{
    display:flex;
    align-items:center;
    gap:10px;
    flex-wrap:wrap;
}

.template-editor-actions .login-button{
    width:auto;
    min-width:190px;
    margin-top:0;
}

.danger-button{
    border-color:#ffd1cc;
    color:#b42318;
    background:#fff5f3;
}

.template-editor-preview{
    position:sticky;
    top:18px;
}

.phone-preview-frame{
    overflow:hidden;
    border:1px solid var(--line);
    border-radius:22px;
    background:#ffffff;
    box-shadow:var(--shadow-card);
}

.phone-preview-top{
    display:flex;
    align-items:center;
    justify-content:space-between;
    min-height:54px;
    padding:0 14px;
    color:#ffffff;
    background:var(--green-dark);
}

.phone-preview-top span{
    width:30px;
    height:4px;
    border-radius:999px;
    background:rgba(255,255,255,.55);
}

.phone-preview-top strong{
    font-size:15px;
}

.phone-preview-chat{
    min-height:520px;
    padding:22px 14px;
    background:
        linear-gradient(rgba(236,229,221,.92), rgba(236,229,221,.92)),
        repeating-linear-gradient(45deg, rgba(0,0,0,.03) 0 1px, transparent 1px 12px);
}

.preview-message-bubble{
    max-width:285px;
    margin-right:auto;
    border-radius:14px 14px 3px 14px;
    background:var(--bubble-out);
    color:var(--text);
    padding:8px;
    box-shadow:0 1px 2px rgba(17,27,33,.16);
}

.phone-preview-frame .preview-image{
    width:100%;
    max-height:245px;
    object-fit:cover;
    border-radius:10px;
    background:#ffffff;
    margin-bottom:8px;
}

.phone-preview-frame .preview-title{
    display:none;
    font-size:14px;
    font-weight:900;
    margin:2px 4px 5px;
}

.phone-preview-frame .preview-body{
    background:transparent;
    padding:0 4px;
    border-radius:0;
    line-height:1.8;
    white-space:pre-wrap;
}

.phone-preview-frame .preview-button{
    display:none;
    align-items:center;
    justify-content:center;
    min-height:38px;
    margin-top:8px;
    border-radius:9px;
    background:#ffffff;
    color:#027eb5;
    font-weight:900;
}

.preview-time{
    margin-top:4px;
    color:#667781;
    font-size:11px;
    text-align:left;
}

.template-edit-form{
    display:grid;
    gap:8px;
    min-width:220px;
}

.template-body-textarea{
    min-width:320px;
    min-height:104px;
}

.template-delete-form{
    margin-top:8px;
}

.status-linked,
.status-unlinked{
    margin-top:6px;
    font-weight:800;
}

.status-linked{
    color:var(--green-dark);
}

.status-unlinked{
    color:#b42318;
}

@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%;
    }

    .send-box{
        gap:7px;
        padding:10px;
    }

    .reactivation-box{
        grid-template-columns:1fr;
        padding:10px;
    }

    .reactivation-box .form-hint{
        grid-column:auto;
    }

    .composer-action-button{
        width:38px;
        min-width:38px;
        height:38px;
    }

    .media-preview{
        min-height:52px;
    }

    .media-preview-thumb{
        width:48px;
        height:48px;
        flex-basis:48px;
    }

    .media-preview-audio{
        width:170px;
        max-width:46vw;
    }

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

    .users-header,
    .users-grid,
    .customers-layout,
    .campaigns-layout,
    .template-editor-layout,
    .customers-card-header,
    .import-template-card,
    .template-tools-grid{
        display:block;
    }

    .template-editor-preview{
        position:static;
        margin-bottom:16px;
    }

    .phone-preview-chat{
        min-height:360px;
    }

    .template-two-columns{
        grid-template-columns:1fr;
    }

    .template-upload-form{
        grid-template-columns:1fr;
        margin-top:14px;
    }

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

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

    .broadcast-card{
        position:static;
    }

    .campaign-create-card{
        position:static;
    }

    .campaign-stat-grid{
        grid-template-columns:repeat(2, minmax(0, 1fr));
    }

    .customers-filter{
        grid-template-columns:1fr;
        margin-top:14px;
    }

    .customers-header-actions{
        display:block;
        margin-top:14px;
    }

    .customer-sync-form .secondary-button{
        width:100%;
    }

    .sync-result-grid{
        grid-template-columns:1fr;
    }
}
