/* ============================================================
   TG Manager v2 — Complete Professional Dark Theme
   ============================================================ */

:root {
    --bg:        #0f1923;
    --bg-2:      #17212b;
    --surface:   #1e2d3a;
    --surface-2: #253443;
    --border:    #2b3e50;
    --border-lt: rgba(255,255,255,.06);
    --primary:   #2aabee;
    --primary-h: #3bb8f5;
    --primary-d: #1e8fcc;
    --accent:    #6c3ce9;
    --text:      #e8edf2;
    --text-2:    #8696a6;
    --text-3:    #5a6a7a;
    --danger:    #f44336;
    --danger-bg: rgba(244,67,54,.1);
    --success:   #4caf50;
    --success-bg:rgba(76,175,80,.1);
    --warn:      #ff9800;
    --warn-bg:   rgba(255,152,0,.1);
    --msg-out:   #2b5278;
    --msg-in:    #182533;
    --radius:    .75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --shadow:    0 4px 24px rgba(0,0,0,.4);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
    --transition:.2s cubic-bezier(.4,0,.2,1);
}

/* ── Reset ────────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box}
html{height:100%;-webkit-text-size-adjust:100%}
body{
    font-family:'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;
    background:var(--bg);
    color:var(--text);
    min-height:100vh;
    margin:0;
    -webkit-font-smoothing:antialiased;
    -moz-osx-font-smoothing:grayscale;
    line-height:1.5;
}
a{color:var(--primary);text-decoration:none;transition:color var(--transition)}
a:hover{color:var(--primary-h)}
::selection{background:var(--primary);color:#fff}
::-webkit-scrollbar{width:6px;height:6px}
::-webkit-scrollbar-track{background:transparent}
::-webkit-scrollbar-thumb{background:var(--border);border-radius:3px}
::-webkit-scrollbar-thumb:hover{background:var(--text-3)}
img{max-width:100%}

/* ── Navbar ───────────────────────────────────────────── */
.tg-navbar{
    background:var(--bg-2);
    border-bottom:1px solid var(--border);
    padding:.6rem 0;
    position:sticky;top:0;z-index:1030;
    backdrop-filter:blur(12px);
}
.tg-brand{
    display:flex;align-items:center;gap:.5rem;
    color:var(--primary)!important;font-weight:700;font-size:1.1rem;
    transition:opacity var(--transition);
}
.tg-brand:hover{opacity:.85;color:var(--primary)!important}
.tg-brand i{font-size:1.4rem}
.nav-link-custom{
    color:var(--text-2);font-size:.85rem;font-weight:500;
    padding:.35rem .65rem;border-radius:var(--radius);
    transition:all var(--transition);display:inline-flex;align-items:center;
}
.nav-link-custom:hover{color:var(--text);background:rgba(255,255,255,.06)}
.tg-btn-ghost{
    background:transparent;border:1px solid var(--border);color:var(--text-2);
    font-size:.82rem;font-weight:500;padding:.3rem .7rem;border-radius:var(--radius);
    transition:all var(--transition);cursor:pointer;
}
.tg-btn-ghost:hover{background:rgba(255,255,255,.06);color:var(--text);border-color:var(--text-3)}
.dropdown-menu-dark{
    background:var(--surface)!important;border:1px solid var(--border)!important;
    border-radius:var(--radius)!important;box-shadow:var(--shadow)!important;
    padding:.35rem!important;
}
.dropdown-menu-dark .dropdown-item{
    color:var(--text-2);border-radius:.4rem;font-size:.85rem;padding:.4rem .7rem;
}
.dropdown-menu-dark .dropdown-item:hover{background:rgba(255,255,255,.06);color:var(--text)}
.dropdown-menu-dark .dropdown-item-text{font-size:.78rem!important}
.dropdown-menu-dark .dropdown-divider{border-color:var(--border)}

/* ── Buttons ──────────────────────────────────────────── */
.tg-btn{
    display:inline-flex;align-items:center;justify-content:center;gap:.35rem;
    font-size:.85rem;font-weight:500;padding:.45rem .9rem;
    border-radius:var(--radius);border:1px solid transparent;
    cursor:pointer;transition:all var(--transition);white-space:nowrap;
    text-decoration:none;line-height:1.4;
}
.tg-btn.btn-sm{padding:.3rem .6rem;font-size:.8rem}
.tg-btn-primary{background:var(--primary);color:#fff;border-color:var(--primary)}
.tg-btn-primary:hover{background:var(--primary-h);border-color:var(--primary-h);color:#fff;box-shadow:0 0 16px rgba(42,171,238,.3)}
.tg-btn-outline{background:transparent;color:var(--text-2);border-color:var(--border)}
.tg-btn-outline:hover{background:rgba(255,255,255,.05);color:var(--text);border-color:var(--text-3)}
.tg-btn-success{background:var(--success);color:#fff;border-color:var(--success)}
.tg-btn-success:hover{background:#5cb860;border-color:#5cb860;color:#fff}
.tg-btn-ghost{background:transparent;border:none;color:var(--text-2);padding:.3rem .5rem}
.tg-btn-ghost:hover{color:var(--text);background:rgba(255,255,255,.06)}
.tg-btn-ghost.text-danger{color:var(--danger)!important}
.tg-btn-ghost.text-danger:hover{background:var(--danger-bg)!important}

.btn-primary-full{
    display:flex;align-items:center;justify-content:center;gap:.4rem;width:100%;
    padding:.65rem;font-size:.92rem;font-weight:600;
    background:var(--primary);color:#fff;border:none;border-radius:var(--radius);
    cursor:pointer;transition:all var(--transition);
}
.btn-primary-full:hover{background:var(--primary-h);box-shadow:0 0 20px rgba(42,171,238,.25)}
.btn-primary-full:active{transform:scale(.98)}
.btn-primary-full:disabled{opacity:.5;cursor:not-allowed}

/* ── Cards ────────────────────────────────────────────── */
.tg-card{
    background:var(--surface);border:1px solid var(--border);
    border-radius:var(--radius-lg);overflow:hidden;
    transition:border-color var(--transition),box-shadow var(--transition);
}
.tg-card:hover{border-color:rgba(42,171,238,.2)}
.tg-card-header{
    padding:1rem 1.25rem .75rem;border-bottom:1px solid var(--border-lt);
}
.tg-card-header h5{margin:0;font-size:1rem;font-weight:600;display:flex;align-items:center}
.tg-card-body{padding:1.25rem}

/* ── Stat Cards ───────────────────────────────────────── */
.stat-card{
    background:var(--surface);border:1px solid var(--border);
    border-radius:var(--radius-lg);padding:1.1rem 1rem;
    display:flex;align-items:center;gap:.85rem;
    transition:all var(--transition);
}
.stat-card:hover{border-color:rgba(42,171,238,.2);box-shadow:var(--shadow-sm)}
.stat-icon{
    width:44px;height:44px;border-radius:12px;
    display:flex;align-items:center;justify-content:center;
    font-size:1.2rem;flex-shrink:0;
}
.stat-icon.blue{background:rgba(42,171,238,.12);color:var(--primary)}
.stat-icon.green{background:var(--success-bg);color:var(--success)}
.stat-icon.cyan{background:rgba(0,188,212,.12);color:#00bcd4}
.stat-icon.purple{background:rgba(108,60,233,.12);color:var(--accent)}
.stat-icon.orange{background:var(--warn-bg);color:var(--warn)}
.stat-icon.red{background:var(--danger-bg);color:var(--danger)}
.stat-value{font-size:1.5rem;font-weight:700;line-height:1.1}
.stat-label{font-size:.78rem;color:var(--text-2);margin-top:.1rem}

.stat-mini{text-align:center;padding:.5rem}
.stat-mini span{display:block;font-size:1.5rem;font-weight:700;color:var(--primary)}

/* ── Account Cards ────────────────────────────────────── */
.account-card{
    background:var(--surface);border:1px solid var(--border);
    border-radius:var(--radius-lg);padding:1rem 1.1rem;
    display:flex;flex-direction:column;gap:.75rem;
    transition:all var(--transition);position:relative;
}
.account-card:hover{border-color:rgba(42,171,238,.18);box-shadow:var(--shadow-sm)}
.account-card.connected{border-left:3px solid var(--success)}
.account-card .account-avatar{
    width:46px;height:46px;border-radius:50%;
    background:linear-gradient(135deg,var(--primary),var(--accent));
    color:#fff;display:flex;align-items:center;justify-content:center;
    font-weight:700;font-size:1.05rem;flex-shrink:0;position:relative;
}
.status-dot{
    position:absolute;bottom:1px;right:1px;width:12px;height:12px;
    border-radius:50%;border:2px solid var(--surface);
}
.status-dot.online{background:var(--success)}
.status-dot.offline{background:var(--text-3)}
.account-info{flex:1;min-width:0}
.account-name{font-weight:600;font-size:.92rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.account-phone{color:var(--text-2);font-size:.8rem;margin-top:.1rem}
.account-username{color:var(--primary);font-size:.8rem}
.account-status{margin-top:.35rem}
.account-actions{
    display:flex;align-items:center;gap:.35rem;flex-wrap:wrap;
    padding-top:.5rem;border-top:1px solid var(--border-lt);
}
.account-backup-info{
    font-size:.75rem;color:var(--text-2);
    padding-top:.4rem;border-top:1px solid var(--border-lt);
}
.spin{animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ── Badges ───────────────────────────────────────────── */
.badge-status{
    display:inline-flex;align-items:center;gap:.25rem;
    font-size:.7rem;font-weight:600;padding:.2rem .55rem;
    border-radius:2rem;letter-spacing:.02em;
}
.badge-status.success{background:var(--success-bg);color:var(--success)}
.badge-status.warning{background:var(--warn-bg);color:var(--warn)}
.badge-status.danger{background:var(--danger-bg);color:var(--danger)}
.badge-status.secondary{background:rgba(255,255,255,.06);color:var(--text-2)}
.badge{font-weight:500;font-size:.72rem;padding:.25rem .55rem;border-radius:2rem}

/* ── Empty State ──────────────────────────────────────── */
.empty-state{
    display:flex;flex-direction:column;align-items:center;justify-content:center;
    padding:3rem 1.5rem;text-align:center;
    background:var(--surface);border:1px dashed var(--border);border-radius:var(--radius-lg);
}
.empty-state i{font-size:3rem;color:var(--text-3);margin-bottom:.75rem}
.empty-state h5{font-weight:600;margin-bottom:.3rem}
.empty-state p{color:var(--text-2);font-size:.88rem;margin-bottom:1rem}

/* ── Forms  ───────────────────────────────────────────── */
.form-group{margin-bottom:1.15rem}
.form-group label{
    display:block;font-size:.8rem;font-weight:500;color:var(--text-2);
    margin-bottom:.35rem;letter-spacing:.02em;
}
.form-group small{display:block;font-size:.72rem;color:var(--text-3);margin-top:.3rem}

.form-input{
    width:100%;padding:.6rem .85rem;font-size:.9rem;
    background:var(--bg-2);color:var(--text);
    border:1px solid var(--border);border-radius:var(--radius);
    outline:none;transition:all var(--transition);
    font-family:inherit;
}
.form-input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(42,171,238,.15)}
.form-input::placeholder{color:var(--text-3)}
.form-input:disabled{opacity:.5;cursor:not-allowed}
.form-input.mono{font-family:'SF Mono','Fira Code',monospace;font-size:.85rem}
.otp-input{
    font-size:1.5rem;font-weight:700;text-align:center;letter-spacing:.5em;
    padding:.7rem;
}

textarea.form-input{resize:vertical;min-height:44px}

/* Bootstrap form override */
.form-control,.form-select{
    background:var(--bg-2)!important;border:1px solid var(--border)!important;
    color:var(--text)!important;border-radius:var(--radius)!important;font-size:.88rem;
}
.form-control:focus,.form-select:focus{
    border-color:var(--primary)!important;
    box-shadow:0 0 0 3px rgba(42,171,238,.15)!important;
}
.form-control::placeholder{color:var(--text-3)!important}
.form-check-input{background-color:var(--border);border-color:var(--text-3)}
.form-check-input:checked{background-color:var(--primary);border-color:var(--primary)}
.form-check-input:focus{box-shadow:0 0 0 3px rgba(42,171,238,.15)}

/* ── Auth Pages ───────────────────────────────────────── */
.auth-page{
    min-height:100vh;display:flex;align-items:center;justify-content:center;
    padding:1.5rem;
    background:
        radial-gradient(ellipse at 30% 20%,rgba(42,171,238,.06) 0%,transparent 50%),
        radial-gradient(ellipse at 70% 80%,rgba(108,60,233,.05) 0%,transparent 50%),
        var(--bg);
}
.auth-card{
    background:var(--surface);border:1px solid var(--border);
    border-radius:var(--radius-xl);padding:2.25rem;
    width:100%;max-width:400px;
    box-shadow:0 12px 48px rgba(0,0,0,.5);
    animation:authIn .4s ease;
}
@keyframes authIn{from{opacity:0;transform:translateY(16px) scale(.98)}to{opacity:1;transform:none}}

.auth-header{text-align:center;margin-bottom:1.5rem}
.auth-logo{
    width:60px;height:60px;border-radius:16px;margin:0 auto .85rem;
    background:linear-gradient(135deg,var(--primary),var(--accent));
    display:flex;align-items:center;justify-content:center;
    box-shadow:0 4px 20px rgba(42,171,238,.3);
}
.auth-logo i{font-size:1.6rem;color:#fff}
.auth-header h2{font-size:1.25rem;font-weight:700;margin:.3rem 0 .2rem}
.auth-header p{font-size:.82rem;color:var(--text-2);margin:0}

.auth-footer{
    text-align:center;margin-top:1.25rem;font-size:.82rem;color:var(--text-2);
    padding-top:1rem;border-top:1px solid var(--border-lt);
}
.auth-footer a{font-weight:500}

/* ── Alerts ───────────────────────────────────────────── */
.alert-danger,.alert.alert-danger{
    background:var(--danger-bg)!important;
    border:1px solid rgba(244,67,54,.2)!important;
    color:#ef9a9a!important;border-radius:var(--radius)!important;
}
.alert-success,.alert.alert-success{
    background:var(--success-bg)!important;
    border:1px solid rgba(76,175,80,.2)!important;
    color:#a5d6a7!important;border-radius:var(--radius)!important;
}
.alert-sm{font-size:.84rem;padding:.6rem .85rem}

/* ── Step Wizard ──────────────────────────────────────── */
.step-bar{
    display:flex;align-items:center;justify-content:center;gap:0;
}
.step-bar .step{
    display:flex;flex-direction:column;align-items:center;gap:.3rem;
    min-width:50px;
}
.step-circle{
    width:32px;height:32px;border-radius:50%;
    display:flex;align-items:center;justify-content:center;
    font-size:.78rem;font-weight:700;
    background:var(--bg-2);color:var(--text-3);
    border:2px solid var(--border);
    transition:all var(--transition);
}
.step-bar .step.active .step-circle{
    background:var(--primary);color:#fff;border-color:var(--primary);
    box-shadow:0 0 12px rgba(42,171,238,.35);
}
.step-bar .step span{font-size:.68rem;color:var(--text-3);font-weight:500}
.step-bar .step.active span{color:var(--primary)}
.step-line{
    width:40px;height:2px;background:var(--border);
    margin:0 .2rem;margin-bottom:1.1rem;
    transition:background var(--transition);
}
.step-line.active{background:var(--primary)}

/* ── Info Box ─────────────────────────────────────────── */
.info-box{
    display:flex;align-items:flex-start;gap:.6rem;
    background:rgba(42,171,238,.06);border:1px solid rgba(42,171,238,.12);
    border-radius:var(--radius);padding:.7rem .85rem;
    font-size:.82rem;color:var(--text-2);line-height:1.55;
}
.info-box i{color:var(--primary);font-size:1rem;flex-shrink:0;margin-top:.1rem}
.info-box code{
    background:rgba(255,255,255,.08);padding:.1rem .35rem;
    border-radius:.25rem;font-size:.78rem;color:var(--primary);
}

/* ── Tables ───────────────────────────────────────────── */
.table-wrap{overflow-x:auto;border-radius:var(--radius);border:1px solid var(--border)}
.tg-table{
    width:100%;color:var(--text);border-collapse:collapse;font-size:.88rem;
}
.tg-table thead th{
    background:var(--bg-2);color:var(--text-2);
    font-weight:600;font-size:.72rem;text-transform:uppercase;letter-spacing:.05em;
    padding:.65rem .85rem;border-bottom:1px solid var(--border);
    white-space:nowrap;position:sticky;top:0;
}
.tg-table tbody td{
    padding:.6rem .85rem;border-bottom:1px solid var(--border-lt);
    vertical-align:middle;
}
.tg-table tbody tr:hover{background:rgba(255,255,255,.02)}
.tg-table tbody tr:last-child td{border-bottom:none}
.mono{font-family:'SF Mono','Fira Code',monospace;font-size:.84rem}

/* ── Loading ──────────────────────────────────────────── */
.loading-spinner{
    display:flex;flex-direction:column;align-items:center;justify-content:center;
    padding:2rem;color:var(--text-3);font-size:.84rem;gap:.5rem;
}
.spinner{
    width:28px;height:28px;
    border:3px solid var(--border);border-top-color:var(--primary);
    border-radius:50%;animation:spin .7s linear infinite;
}

/* ==========================================================================
   CHAT LAYOUT
   ========================================================================== */

.chat-container{
    display:flex;height:100vh;height:100dvh;overflow:hidden;background:var(--bg);
}

/* ── Sidebar ──────────────── */
.chat-sidebar{
    width:340px;min-width:340px;background:var(--bg-2);
    border-right:1px solid var(--border);
    display:flex;flex-direction:column;overflow:hidden;
}
.sidebar-header{
    display:flex;align-items:center;gap:.65rem;
    padding:.7rem 1rem;border-bottom:1px solid var(--border);min-height:54px;
}
.sidebar-back{
    color:var(--text-2);font-size:1.15rem;
    display:flex;align-items:center;justify-content:center;
    width:34px;height:34px;border-radius:50%;transition:all var(--transition);
}
.sidebar-back:hover{background:rgba(255,255,255,.06);color:var(--text)}
.sidebar-title{flex:1;min-width:0}
.sidebar-name{display:block;font-weight:600;font-size:.9rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sidebar-phone{font-size:.72rem;color:var(--text-3)}
.sidebar-menu{
    background:none;border:none;color:var(--text-2);
    width:34px;height:34px;display:flex;align-items:center;justify-content:center;
    border-radius:50%;font-size:1.05rem;cursor:pointer;transition:all var(--transition);
}
.sidebar-menu:hover{background:rgba(255,255,255,.06);color:var(--text)}

.sidebar-search{padding:.4rem .7rem;position:relative}
.sidebar-search i{
    position:absolute;left:1.15rem;top:50%;transform:translateY(-50%);
    color:var(--text-3);font-size:.82rem;pointer-events:none;
}
.sidebar-search input{
    width:100%;background:var(--surface);border:1px solid transparent;
    border-radius:2rem;padding:.45rem .85rem .45rem 2.1rem;
    color:var(--text);font-size:.84rem;outline:none;
    transition:all var(--transition);
}
.sidebar-search input:focus{border-color:var(--primary);box-shadow:0 0 0 2px rgba(42,171,238,.12)}
.sidebar-search input::placeholder{color:var(--text-3)}

/* ── Dialog List ──────────── */
.dialog-list{flex:1;overflow-y:auto;overflow-x:hidden}
.dialog-item{
    display:flex;align-items:center;gap:.7rem;
    padding:.55rem .85rem;cursor:pointer;transition:background .12s;
    border-left:3px solid transparent;
}
.dialog-item:hover{background:rgba(255,255,255,.03)}
.dialog-item.active{background:rgba(42,171,238,.1);border-left-color:var(--primary)}
.dialog-item.active .dialog-name{color:var(--primary)}
.dialog-item.active .dialog-time{color:var(--primary)}

.dialog-avatar{
    width:44px;height:44px;border-radius:50%;
    background:linear-gradient(135deg,var(--primary),var(--accent));
    color:#fff;display:flex;align-items:center;justify-content:center;
    font-weight:600;font-size:.9rem;flex-shrink:0;overflow:hidden;
}
.dialog-avatar img{width:100%;height:100%;object-fit:cover}
.dialog-content{flex:1;min-width:0}
.dialog-top{display:flex;justify-content:space-between;align-items:baseline}
.dialog-name{font-weight:600;font-size:.88rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;transition:color .12s}
.dialog-time{font-size:.68rem;color:var(--text-3);flex-shrink:0;margin-left:.4rem}
.dialog-preview{font-size:.78rem;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}
.dialog-unread{
    background:var(--primary);color:#fff;font-size:.62rem;font-weight:700;
    min-width:20px;height:20px;border-radius:10px;
    display:flex;align-items:center;justify-content:center;padding:0 5px;flex-shrink:0;
}

/* ── Chat Main ────────────── */
.chat-main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0}
.chat-empty{
    flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;
    color:var(--text-3);gap:.3rem;
}
.chat-empty i{font-size:3.5rem;margin-bottom:.5rem;opacity:.5}
.chat-empty h5{color:var(--text);font-weight:600;font-size:1rem;margin:0}
.chat-empty p{font-size:.84rem;margin:0}
.chat-view{flex:1;display:flex;flex-direction:column;overflow:hidden}

/* Chat Header */
.chat-header{
    display:flex;align-items:center;gap:.7rem;
    padding:.55rem 1rem;background:var(--bg-2);
    border-bottom:1px solid var(--border);min-height:54px;
}
.chat-back-btn{
    display:none;background:none;border:none;
    color:var(--text-2);font-size:1.15rem;padding:.2rem;cursor:pointer;
}
.chat-header-avatar{
    width:38px;height:38px;border-radius:50%;
    background:linear-gradient(135deg,var(--primary),var(--accent));
    color:#fff;display:flex;align-items:center;justify-content:center;
    font-weight:600;font-size:.85rem;flex-shrink:0;overflow:hidden;
}
.chat-header-avatar img{width:100%;height:100%;object-fit:cover}
.chat-header-info{flex:1;min-width:0}
.chat-header-name{font-weight:600;font-size:.92rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-header-status{font-size:.72rem;color:var(--text-3)}

/* Messages */
.chat-messages{
    flex:1;overflow-y:auto;overflow-x:hidden;
    padding:.75rem 1rem;display:flex;flex-direction:column;
    background:var(--bg);
}
.chat-messages .loading-spinner{margin:auto}
.msg-date-divider{text-align:center;padding:.6rem 0;font-size:.72rem;color:var(--text-3)}
.msg-date-divider span{background:rgba(0,0,0,.5);padding:.2rem .7rem;border-radius:1rem}

.msg-bubble{
    max-width:65%;padding:.45rem .8rem;border-radius:.8rem;
    font-size:.88rem;line-height:1.45;position:relative;
    word-wrap:break-word;margin-bottom:2px;
}
.msg-out{background:var(--msg-out);align-self:flex-end;border-bottom-right-radius:.2rem}
.msg-in{background:var(--msg-in);align-self:flex-start;border-bottom-left-radius:.2rem}
.msg-sender{font-size:.72rem;font-weight:600;color:var(--primary);margin-bottom:2px}
.msg-text{white-space:pre-wrap}
.msg-media{max-width:100%;border-radius:.5rem;margin-bottom:.2rem}
.msg-media img{max-width:100%;max-height:300px;border-radius:.5rem;cursor:pointer}
.msg-time{font-size:.62rem;color:rgba(255,255,255,.4);text-align:right;margin-top:2px}

/* Input Area */
.chat-input-area{
    display:flex;align-items:flex-end;gap:.4rem;
    padding:.55rem .85rem;background:var(--bg-2);border-top:1px solid var(--border);
}
.chat-attach-btn,.chat-send-btn{
    background:none;border:none;color:var(--text-3);font-size:1.2rem;
    padding:.3rem;cursor:pointer;border-radius:50%;
    transition:all var(--transition);flex-shrink:0;
    display:flex;align-items:center;justify-content:center;width:38px;height:38px;
}
.chat-attach-btn:hover{color:var(--text);background:rgba(255,255,255,.06)}
.chat-send-btn{color:var(--primary)}
.chat-send-btn:hover{background:rgba(42,171,238,.1)}

.chat-input{
    flex:1;background:var(--surface);border:1px solid transparent;
    border-radius:1.2rem;padding:.5rem .9rem;color:var(--text);
    font-size:.88rem;resize:none;max-height:120px;outline:none;
    line-height:1.4;font-family:inherit;transition:border-color var(--transition);
}
.chat-input:focus{border-color:var(--primary)}
.chat-input::placeholder{color:var(--text-3)}

/* Contacts Panel */
.contacts-panel{
    position:fixed;top:0;left:0;width:340px;height:100%;
    background:var(--bg-2);z-index:1040;border-right:1px solid var(--border);
    display:flex;flex-direction:column;box-shadow:4px 0 24px rgba(0,0,0,.5);
}
.contacts-header{
    display:flex;align-items:center;gap:.7rem;
    padding:.7rem 1rem;border-bottom:1px solid var(--border);
}
.contacts-header button{background:none;border:none;color:var(--text-2);font-size:1.15rem;cursor:pointer}
.contacts-header h6{margin:0;font-weight:600}
.contacts-list{flex:1;overflow-y:auto}
.contact-item{
    display:flex;align-items:center;gap:.7rem;
    padding:.5rem .85rem;cursor:pointer;transition:background .12s;
}
.contact-item:hover{background:rgba(255,255,255,.03)}

/* ── Bootstrap overrides for admin/backup pages ──── */
.btn-primary{
    background:var(--primary)!important;border-color:var(--primary)!important;
    color:#fff!important;font-weight:500;border-radius:var(--radius);
    transition:all var(--transition);
}
.btn-primary:hover{background:var(--primary-h)!important;border-color:var(--primary-h)!important;box-shadow:0 0 14px rgba(42,171,238,.25)}
.btn-outline-light{border-color:var(--border);color:var(--text-2);border-radius:var(--radius)}
.btn-outline-light:hover{background:rgba(255,255,255,.06);color:var(--text)}
.btn-outline-info{border-color:rgba(42,171,238,.25);color:var(--primary);border-radius:var(--radius)}
.btn-outline-info:hover{background:rgba(42,171,238,.08);color:var(--primary-h)}
.btn-outline-warning{border-color:rgba(255,152,0,.25);color:var(--warn);border-radius:var(--radius)}
.btn-outline-warning:hover{background:var(--warn-bg);color:var(--warn)}
.btn-outline-success{border-color:rgba(76,175,80,.25);color:var(--success);border-radius:var(--radius)}
.btn-outline-success:hover{background:var(--success-bg);color:var(--success)}
.btn-outline-danger{border-color:rgba(244,67,54,.25);color:var(--danger);border-radius:var(--radius)}
.btn-outline-danger:hover{background:var(--danger-bg);color:var(--danger)}
.btn-outline-secondary{border-color:var(--border);color:var(--text-2);border-radius:var(--radius)}
.btn-outline-secondary:hover{background:rgba(255,255,255,.05);color:var(--text)}

/* Badges */
.bg-success{background:var(--success)!important}
.bg-danger{background:var(--danger)!important}
.bg-warning{background:var(--warn)!important}
.bg-info{background:var(--primary)!important}
.bg-secondary{background:var(--text-3)!important}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media(max-width:768px){
    .chat-sidebar{width:100%;min-width:100%;position:absolute;top:0;left:0;height:100%;z-index:10}
    .chat-main{width:100%}
    .chat-sidebar.hidden{display:none}
    .chat-back-btn{display:flex}
    .contacts-panel{width:100%}
    .msg-bubble{max-width:85%}
    .account-card:hover{box-shadow:none}
}
@media(max-width:480px){
    .auth-card{padding:1.5rem;margin:.5rem}
    .sidebar-header,.dialog-item,.chat-header,.chat-input-area{padding-left:.65rem;padding-right:.65rem}
    .msg-bubble{max-width:90%;font-size:.84rem}
    .stat-card{padding:.75rem}
    .stat-value{font-size:1.25rem}
    .stat-icon{width:38px;height:38px;font-size:1rem}
}

@media print{
    .chat-sidebar,.chat-input-area,.tg-navbar{display:none!important}
    .chat-main{display:block}
    .chat-messages{overflow:visible;height:auto}
}
