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

body,
.app,
.wrapper,
.layout,
.page,
.main-wrapper,
.content-wrapper {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

* {
    box-sizing: border-box;
}

body {
    background: #0f1317;
    color: #e8eaed;
    font-family: Segoe UI, Tahoma, Arial, sans-serif;
}

a {
    color: #d9dde3;
}

.topbar {
    width: 100%;
    height: 68px;
    background: #0f1114;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    box-sizing: border-box;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin: -20px 0 0 0 !important;
}

.mobile-menu-toggle {
    display: none;
    background: transparent !important;
    border: 0 !important;
    padding: 8px !important;
    box-shadow: none !important;
}

.mobile-menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #ffffff;
    margin: 5px 0;
    border-radius: 999px;
}

.topbar-brand {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: .15px;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1;
}

.topbar-logo {
    width: 30px;
    height: 30px;
    display: block;
}

.topbar-brand span {
    font-size: 22px;
    font-weight: 700;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 46%;
    white-space: nowrap;
    overflow: hidden;
    line-height: 1;
}

.avatar-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #232a30;
    border: 1px solid rgba(255,255,255,0.25);
    flex: 0 0 28px;
}

.topbar-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-caret {
    color: #c8ced6;
    font-size: 11px;
}

.app-shell {
    display: flex;
    min-height: calc(100vh - 68px);
}

.sidebar {
    width: 274px;
    background: #11161a;
    border-right: 1px solid rgba(255,255,255,0.08);
    padding: 18px 14px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar a {
    color: #d9dde3;
    text-decoration: none;
    padding: 12px 12px;
    border-radius: 12px;
    transition: background .2s ease, color .2s ease;
}

.sidebar-link {
    display: block;
}

.sidebar a:hover,
.sidebar a.active {
    background: rgba(255,255,255,0.06);
    color: #35d06f;
}

.main-content {
    flex: 1;
    background: #0f1317;
    padding: 28px 32px;
    min-width: 0;
}

.page-inner {
    padding: 0;
}

.warning {
    font-size: 13px;
    color: #f5d07d;
    background: rgba(217,151,6,0.12);
    border: 1px solid rgba(217,151,6,0.35);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 14px;
}

.card,
.panel,
.table-wrapper,
.form-box {
    background: linear-gradient(145deg, #1b2025, #15191d);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.22);
}

.card {
    padding: 16px;
    margin-bottom: 20px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat {
    padding: 14px;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
}

.stat strong {
    font-size: 30px;
    color: #ffffff;
}

.stat div {
    color: #aeb8c4;
    margin-top: 4px;
}

.alert {
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.alert.success {
    background: rgba(22,163,74,0.18);
    color: #88e3a9;
    border: 1px solid rgba(22,163,74,0.35);
}

.alert.error {
    background: rgba(220,38,38,0.18);
    color: #ffacac;
    border: 1px solid rgba(220,38,38,0.35);
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    color: #e8eaed;
    background: transparent;
}

th {
    color: #ffffff;
    background: rgba(255,255,255,0.03);
    font-weight: 700;
}

td, th {
    border-bottom: 1px solid rgba(255,255,255,0.08);
    border-right: 1px solid rgba(255,255,255,0.08);
    padding: 14px 16px;
    text-align: left;
    vertical-align: middle;
}
td:last-child,
th:last-child {
    border-right: none;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #dbe2ea;
}

.form-group,
.field,
.form-field,
.form-row > div,
.form-grid > div {
    margin-bottom: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 12px;
}

.form-section-spacing {
    margin-top: 12px;
}

input, select, textarea, button {
    padding: 10px 11px;
    border-radius: 10px;
    font-size: 14px;
    border: 1px solid rgba(255,255,255,0.12);
}

input, select, textarea {
    width: 100%;
    background: #0f1419;
    color: #e8eaed;
}

textarea {
    min-height: 110px;
}

button {
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: #ffffff;
    border: none;
    cursor: pointer;
    transition: background .2s ease;
    font-weight: 700;
    border-radius: 8px;
    padding: 10px 16px;
}

button:hover {
    background: linear-gradient(135deg, #15803d, #16a34a);
}

.btn-small {
    width: auto;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 9px;
}

.btn-draft {
    background: #0b0f12 !important;
    border: 1px solid #2b343c !important;
    color: #fff !important;
}

.btn-draft:hover {
    background: #151b20 !important;
}

.inline {
    display: flex;
    gap: 8px;
    align-items: end;
    flex-wrap: wrap;
}

.dashboard-filter-inline .form-group {
    margin-bottom: 0;
}

.dashboard-filter-inline .filter-action {
    margin-bottom: 0;
    align-self: flex-end;
}

.dashboard-home-filters-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(170px, 1fr));
    gap: 12px;
    align-items: end;
}

.dashboard-home-filters .form-group {
    margin-bottom: 12px;
}

.dashboard-apply-group {
    display: flex;
    align-items: flex-end;
}

.dashboard-apply-group .btn-small {
    min-height: 40px;
}

.actions-row {
    margin-top: 18px;
}

.dashboard-grid,
.cards-grid,
.stats-grid {
    display: grid;
    gap: 16px;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 14px;
}

.stat-card {
    display: flex;
    gap: 14px;
    align-items: center;
}

.stat-icon {
    width: 58px;
    height: 58px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #fff;
    font-weight: 700;
}

.icon-green { background: linear-gradient(135deg, #16a34a, #22c55e); }
.icon-blue { background: linear-gradient(135deg, #2563eb, #3b82f6); }
.icon-yellow { background: linear-gradient(135deg, #d97706, #f59e0b); }
.icon-red { background: linear-gradient(135deg, #dc2626, #ef4444); }

.stat-number {
    font-size: 40px;
    line-height: 1;
    font-weight: 800;
    color: #fff;
}

.dashboard-panels-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-top: 14px;
    margin-bottom: 14px;
}

.dashboard-panels-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 14px;
    margin-bottom: 10px;
}

.chart-box {
    min-height: 250px;
    margin-top: 0;
    margin-bottom: 14px;
}

.chart-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

.chart-box canvas {
    max-height: 300px;
}

.dashboard-panels-3 .chart-box canvas {
    max-height: 230px;
}

.dashboard-charts-main,
.dashboard-main-charts,
.charts-row {
    margin-top: 10px !important;
    margin-bottom: 10px !important;
    gap: 14px !important;
}

.dashboard-charts-main .chart-card,
.dashboard-main-charts .chart-card,
.charts-row .chart-card {
    margin-top: 0 !important;
    margin-bottom: 8px !important;
}

.dashboard-charts-main .chart-box,
.dashboard-main-charts .chart-box,
.charts-row .chart-box {
    margin-top: 0 !important;
    margin-bottom: 8px !important;
}

.dashboard-charts-secondary {
    margin-top: 14px !important;
    margin-bottom: 10px !important;
    gap: 14px !important;
}

.dashboard-charts-secondary .chart-card canvas,
.dashboard-charts-secondary .chart-box canvas {
    max-height: 230px;
}

.actions-top-right {
    display: flex;
    justify-content: flex-end;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.badge.gray, .badge-secondary { background: #6b7280; }
.badge.green, .badge-success { background: #16a34a; }
.badge.yellow, .badge-warning { background: #d97706; }
.badge.red, .badge-danger { background: #dc2626; }
.badge.blue, .badge-primary { background: #2563eb; }

.progress {
    width: 100%;
    height: 18px;
    background: rgba(255,255,255,0.12);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    min-width: 0;
    background: #1fb85c;
    color: #fff;
    text-align: center;
    font-size: 12px;
    line-height: 18px;
    transition: width .3s ease;
}

body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f1317;
}

.login-card {
    width: 100%;
    max-width: 430px;
    background: linear-gradient(145deg, #1b2025, #15191d);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.28);
    padding: 22px;
}

.login-card h2 {
    margin-top: 0;
    color: #ffffff;
}

.login-card label {
    color: #e5e7eb;
}

.login-card input {
    background: #11161a;
    border: 1px solid rgba(255,255,255,0.12);
    color: #ffffff;
}

.login-tip {
    font-size: 12px;
    color: #9ca3af;
    margin-top: 12px;
}

.conversation-filters {
    margin-top: 0;
    margin-bottom: 28px;
    padding-bottom: 12px;
}

.conversation-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    align-items: end;
}

.conversation-filters .form-group {
    margin-bottom: 12px;
}

.conversation-filter-actions,
.filters-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 0;
}

.conversation-filter-actions .btn-small,
.conversation-filter-actions .btn-link-reset,
.filters-actions .btn-small,
.filters-actions .btn-link-reset {
    min-height: 40px;
    align-self: flex-end;
}

.btn-link-reset {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.14);
    color: #e8eaed;
    text-decoration: none;
    background: rgba(255,255,255,0.03);
}

.btn-link-reset:hover {
    background: rgba(255,255,255,0.08);
}

.conversation-grid,
.conversations-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
    align-items: start;
}

.conversation-app {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 18px;
    height: calc(100vh - 180px);
    min-height: 0;
    overflow: hidden;
}

body.conversations-body {
    height: 100vh;
    overflow: hidden;
}

body.conversations-body .main-content {
    height: calc(100vh - 68px);
    overflow: hidden;
}

body.conversations-body .page-inner {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 12px;
}

body.conversations-body .conversations-page {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conversation-list-card,
.conversations-list {
    min-height: 0;
    height: 100%;
    overflow: auto;
    padding: 10px;
}

.conversation-quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.conversation-quick-btn {
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.04);
    color: #e8eaed;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 10px;
    cursor: pointer;
}

.conversation-quick-btn.is-active {
    background: #22c55e;
    color: #ffffff;
    border-color: #22c55e;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 10px;
}

.conversation-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 42px;
    background: #263038;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 15px;
}

.conversation-avatar-fallback {
    text-transform: uppercase;
}

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

.conversation-header-contact {
    display: flex;
    align-items: center;
    gap: 10px;
}

.conversation-avatar-header {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
}

.conversation-item.active {
    border-color: #22c55e;
    background: rgba(34,197,94,0.12);
}

.conversation-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.conversation-preview {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    max-height: calc(1.35em * 2);
    word-break: break-word;
}

.conversation-detail-card,
.conversation-thread {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
    overflow: hidden;
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.conversation-header-actions {
    display: flex;
    align-items: center !important;
    justify-content: flex-end;
    gap: 8px;
}

.conversation-status-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conversation-header-actions .conversation-action-btn,
.conversation-header-actions .connection-status,
.conversation-header-actions .polling-indicator {
    height: 34px !important;
    min-height: 34px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    line-height: 34px !important;
    box-sizing: border-box;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    font-size: 13px;
    font-weight: 600;
    border-radius: 10px;
}

.conversation-header-actions .polling-indicator {
    font-size: 13px !important;
    font-weight: 600 !important;
    transform: none !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

.connection-status {
    border-radius: 999px;
}

.polling-indicator {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.18);
}

.polling-indicator.online {
    color: #86efac;
    background: rgba(22,163,74,0.2);
    border-color: rgba(22,163,74,0.45);
}

.polling-indicator.reconnecting {
    color: #fcd34d;
    background: rgba(217,119,6,0.18);
    border-color: rgba(217,119,6,0.45);
}

.polling-indicator.syncing {
    color: #bfdbfe;
    background: rgba(37,99,235,0.18);
    border-color: rgba(37,99,235,0.45);
}

.conversation-messages {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: transparent;
    border-radius: 10px;
}

.conversation-messages::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("/assets/logo/bg-wp.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

.messages-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
}

.messages-inner > * {
    position: relative;
    z-index: 1;
}

.msg-row {
    display: flex;
    margin-bottom: 10px;
}

.msg-row.in {
    justify-content: flex-start;
    margin-left: 20px;
}

.msg-row.out {
    justify-content: flex-end;
    margin-right: 20px;
}

.msg-bubble {
    max-width: 72%;
    border-radius: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
}

.msg-bubble a {
    color: #8ab4ff;
    text-decoration: underline;
    word-break: break-word;
}

.msg-bubble a:hover {
    color: #b6d0ff;
}

.msg-row.out .msg-bubble {
    background: rgba(34,197,94,0.16);
    border-color: rgba(34,197,94,0.35);
}

.msg-bubble small,
.conversation-line small {
    font-size: 11px;
    color: #b8c0c7;
}

.message-time {
    display: block;
    margin-top: 5px;
}

.message-text,
.chat-media,
.chat-video-wrap,
.chat-audio-wrap,
.chat-document-wrap {
    margin-bottom: 5px;
}

.badge-unread {
    background: #22c55e !important;
    color: #ffffff !important;
}

.conversation-reply,
.chat-composer {
    padding-top: 8px;
    padding-bottom: 20px !important;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex: 0 0 auto;
    margin-bottom: 0 !important;
    min-height: 0 !important;
}

.chat-composer {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.conversation-reply-toolbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: start;
    min-height: 0;
}

.composer-tools {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversation-reply-toolbar textarea {
    min-height: 0;
    height: auto;
    line-height: 1.35;
    margin-bottom: 0;
}

.attachment-preview {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.03);
}

.attachment-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#attachmentPreviewImage {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.14);
}

#attachmentPreviewName {
    font-size: 12px;
    color: #d9dde3;
    word-break: break-word;
}

.emoji-panel {
    margin-top: 0;
}

.emoji-panel button {
    min-width: 36px;
    padding: 6px 8px;
}

.emoji-button,
.attachment-button {
    width: 34px;
    height: 34px;
    background: transparent !important;
    border: 1px solid #3a444d !important;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    color: #e8eaed;
    line-height: 1;
    padding: 0;
}

.emoji-panel button {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #e8eaed;
}

.emoji-button:hover,
.attachment-button:hover,
.emoji-panel button:hover {
    background: rgba(255,255,255,0.08) !important;
}

.emoji-picker {
    position: absolute;
    left: 16px;
    bottom: 64px;
    z-index: 50;
    display: none;
    background: #151b20;
    border: 1px solid #2b343c;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 0 12px 30px rgba(0,0,0,.35);
    flex-wrap: wrap;
    gap: 6px;
    max-width: 300px;
}

.emoji-picker.is-open {
    display: flex;
}

.msg-media {
    margin-top: 8px;
}

.conversation-list-card::-webkit-scrollbar,
.messages-inner::-webkit-scrollbar {
  width: 8px;
}

.conversation-list-card::-webkit-scrollbar-track,
.messages-inner::-webkit-scrollbar-track {
  background: #11161a;
}

.conversation-list-card::-webkit-scrollbar-thumb,
.messages-inner::-webkit-scrollbar-thumb {
  background: #263038;
  border-radius: 8px;
}

.conversation-list-card::-webkit-scrollbar-thumb:hover,
.messages-inner::-webkit-scrollbar-thumb:hover {
  background: #33414b;
}

.chat-image {
    max-width: 180px;
    border-radius: 8px;
    cursor: pointer;
}

.chat-video {
    max-width: 220px;
}

.chat-video-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.media-expand-btn {
    align-self: flex-start;
}

.doc-card {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: rgba(255,255,255,0.03);
}

.media-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.media-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.78);
}

.media-modal-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 86vh;
}

.media-modal-close {
    position: absolute;
    top: -38px;
    right: 0;
    min-width: 36px;
    min-height: 36px;
}

.queue-summary,
.queue-stats,
.queue-cards {
    display: grid;
    gap: 18px;
    margin-bottom: 22px;
}

.queue-filters,
.queue-table,
.table-wrapper {
    margin-top: 18px;
    margin-bottom: 22px;
}

.queue-filters-grid {
    grid-template-columns: repeat(8, minmax(140px, 1fr));
    align-items: end;
    gap: 12px;
}

.queue-filters-grid .form-group {
    margin-bottom: 0;
}

.queue-filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.queue-filter-actions .btn-small,
.queue-filter-actions .btn-link-reset {
    min-height: 40px;
}

.logs-filters-grid {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
    align-items: end;
    gap: 12px;
}

.logs-filters-grid .form-group {
    margin-bottom: 0;
}

.logs-filter-action {
    display: flex;
    align-items: flex-end;
}

.logs-filter-action .btn-small {
    min-height: 40px;
}

.senders-toolbar-card {
    margin-bottom: 20px;
}

.senders-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: nowrap;
}

.senders-toolbar .form-group {
    margin-bottom: 0;
}

.senders-filter-group {
    min-width: 220px;
}

.senders-filter-group select {
    min-height: 40px;
}

.senders-filter-action {
    display: flex;
    align-items: flex-end;
}

.senders-filter-action button,
.senders-toolbar a button {
    min-height: 40px;
}

.senders-toolbar-separator {
    color: #8d98a6;
    font-weight: 600;
    line-height: 40px;
    align-self: flex-end;
    margin: 0 2px;
}

@media (max-width: 980px) {
    .topbar {
        height: 70px;
        padding: 0 14px;
    }

    .topbar-brand { font-size: 20px; }

    .topbar-user {
        max-width: 60%;
        font-size: 13px;
    }

    .app-shell {
        flex-direction: column;
        min-height: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.08);
    }

    .page-inner {
        padding: 16px;
    }

    .main-content {
        padding: 0;
    }

    .dashboard-panels-2,
    .dashboard-panels-3 {
        grid-template-columns: 1fr;
    }

    .conversation-grid,
    .conversations-layout,
    .conversation-app {
        grid-template-columns: 1fr;
    }

    .conversation-list-card,
    .conversations-list {
        max-height: 280px;
        min-height: 240px;
    }

    .conversation-detail-card,
    .conversation-thread {
        min-height: 320px;
    }

    .dashboard-home-filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .senders-toolbar {
        flex-wrap: wrap;
    }

    .senders-toolbar-separator {
        display: none;
    }

    .queue-filters-grid {
        grid-template-columns: 1fr 1fr;
    }

    .logs-filters-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-home-filters-grid {
        grid-template-columns: 1fr;
    }

    .senders-toolbar {
        align-items: stretch;
        gap: 10px;
    }

    .senders-toolbar a,
    .senders-filter-group,
    .senders-filter-action {
        width: 100%;
    }

    .queue-filters-grid {
        grid-template-columns: 1fr;
    }

    .queue-filter-actions {
        width: 100%;
    }

    .logs-filters-grid {
        grid-template-columns: 1fr;
    }

    .logs-filter-action {
        width: 100%;
    }
}

/* Conversation hard-fix alignment layer */
body.conversations-body .conversation-filters-grid {
    align-items: end !important;
}

body.conversations-body .conversation-filters .form-group {
    margin-bottom: 0 !important;
}

body.conversations-body .conversation-filters .form-group select,
body.conversations-body .conversation-filters .form-group input {
    min-height: 40px;
}

body.conversations-body .conversation-filter-actions,
body.conversations-body .filters-actions {
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
    margin: 0 !important;
    min-height: 40px;
}

body.conversations-body .conversation-filter-actions .btn-small,
body.conversations-body .conversation-filter-actions .btn-link-reset,
body.conversations-body .filters-actions .btn-small,
body.conversations-body .filters-actions .btn-link-reset {
    min-height: 40px !important;
    height: 40px !important;
}

body.conversations-body .conversation-header {
    display: flex;
    align-items: center !important;
    justify-content: space-between !important;
}

body.conversations-body .conversation-header-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 8px !important;
}

body.conversations-body .conversation-status-form {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

body.conversations-body .conversation-header-actions .conversation-action-btn,
body.conversations-body .conversation-header-actions .connection-status,
body.conversations-body .conversation-header-actions .polling-indicator {
    height: 34px !important;
    min-height: 34px !important;
    line-height: 34px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    white-space: nowrap;
}

body.conversations-body .chat-composer {
    padding-top: 8px !important;
    padding-bottom: 20px !important;
    margin-bottom: 0 !important;
    min-height: 0 !important;
}

body.conversations-body .conversation-reply-toolbar {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    align-items: start !important;
    gap: 10px !important;
}

body.conversations-body .composer-tools {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    align-items: center;
}

body.conversations-body .emoji-button,
body.conversations-body .attachment-button {
    width: 34px !important;
    height: 34px !important;
    min-height: 34px !important;
    background: transparent !important;
    border: 1px solid #3a444d !important;
    border-radius: 10px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
}

body.conversations-body .conversation-reply-toolbar textarea {
    min-height: 78px !important;
    height: auto !important;
    margin: 0 !important;
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: inline-flex;
        flex-direction: column;
        margin-right: 6px;
    }

    .topbar-user {
        display: none !important;
    }

    .topbar {
        justify-content: flex-start;
        gap: 12px;
        height: 68px;
    }

    .topbar-brand span {
        font-size: 20px;
    }

    .topbar-logo {
        width: 28px;
        height: 28px;
    }

    .app-shell {
        position: relative;
    }

    .sidebar {
        position: fixed;
        top: 68px;
        left: -260px;
        width: 250px;
        height: calc(100vh - 68px);
        z-index: 999;
        transition: left .25s ease;
        border-right: 1px solid rgba(255,255,255,0.08);
    }

    body.sidebar-open .sidebar {
        left: 0;
    }

    .main-content {
        width: 100%;
        padding: 18px;
    }
}

/* Final surgical conversation alignment override */
body.conversations-body .conversation-header-actions {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: 8px !important;
}

body.conversations-body .conversation-header-actions > * {
    height: 34px !important;
    min-height: 34px !important;
    max-height: 34px !important;
    padding: 0 14px !important;
    margin: 0 !important;
    line-height: 1 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    vertical-align: middle !important;
    position: static !important;
    top: auto !important;
    transform: none !important;
}

body.conversations-body .conversation-header-actions .conversation-status-inline {
    display: inline-flex !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.conversations-body .conversation-header-actions .conversation-status-inline .conversation-action-btn {
    height: 100% !important;
    min-height: 34px !important;
    margin: 0 !important;
}

body.conversations-body .conversation-header-actions .connection-status {
    border-radius: 999px !important;
    min-width: 130px !important;
    width: 130px !important;
    max-width: 130px !important;
    text-align: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
}

@media (max-width: 768px) {
    body.conversations-body .conversation-header-actions .connection-status {
        min-width: 118px !important;
        width: 118px !important;
        max-width: 118px !important;
    }
}

body.conversations-body .conversation-messages {
    height: calc(100% - 35px) !important;
}

body.conversations-body .messages-inner {
    padding: 8px 0 !important;
}

body.conversations-body .chat-composer {
    padding-top: 8px !important;
    padding-bottom: 20px !important;
    margin-bottom: 0 !important;
    min-height: auto !important;
    height: auto !important;
    flex: 0 0 auto !important;
}

body.conversations-body .composer-wrap,
body.conversations-body .reply-box {
    margin-bottom: 0 !important;
    padding-bottom: 20px !important;
    min-height: auto !important;
    height: auto !important;
}

body.conversations-body .conversation-reply {
    margin-bottom: 0 !important;
    padding-bottom: 20px !important;
}

body.conversations-body .conversation-reply form {
    margin: 0 !important;
    padding: 0 !important;
}

body.conversations-body .conversation-reply-toolbar {
    align-items: flex-end !important;
}

body.conversations-body .conversation-reply-toolbar textarea {
    min-height: 64px !important;
}

body.conversations-body .conversation-detail-card {
    padding-bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

body.conversations-body .messages-area,
body.conversations-body .conversation-messages {
    flex: 1 1 auto !important;
    min-height: 0 !important;
}
