/* ===========================================
   chat-ui.css
   ===========================================
   Styles for in-app messaging components
   =========================================== */

/* =========================
   Chat Header (Pinned Load Summary)
   ========================= */
.chat-header {
    position: sticky;
    top: 0;
    z-index: 50; /* Changed from 100 */
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 14px 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.chat-header-compact {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px;
    margin: 0;
    border: 1px solid #e2e8f0;
}

.chat-header-title {
    flex: 1;
    font-size: 16px;
    font-weight: 700;
    color: #0b7d62; /* Always green to indicate it's tappable */
    cursor: pointer;
    user-select: none;
    padding: 10px 12px;
    margin: -10px -12px;
    border-radius: 8px;
    transition: background 0.15s ease;
    -webkit-tap-highlight-color: rgba(11, 125, 98, 0.1);
}

/* ✅ ADD THIS NEW RULE */
.chat-header-title:hover {
    color: #0b7d62;
}

.chat-header-title:active {
    background: rgba(11, 125, 98, 0.08);
}

.chat-load-route {
    font-size: 13px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.chat-load-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #64748b;
    margin-top: 6px;
}

.chat-load-price {
    font-weight: 700;
    color: #0b7d62;
}

.chat-load-id {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
}

/* =========================
   Messages Container - FIXED
   ========================= */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1; /* Take all remaining space after header */
    background: #fafafa;
    overflow: hidden;
    position: relative;
    min-height: 0; /* Important for flexbox scrolling */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    padding-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    transition: margin-bottom 0.22s ease;
}

.chat-messages::before {
    content: "";
    margin-top: auto;
}

.chat-input {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 15px;
    color: #1e293b;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    padding: 9px 16px;
    overflow-y: auto;
    
    /* Hide scrollbar completely */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.chat-input::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

/* =========================
   Message Bubbles
   ========================= */
.message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    position: relative;
    line-height: 1.4;
    word-wrap: break-word;
    user-select: text;
    -webkit-user-select: text;
    /* No animation by default — only new bubbles get it via .message-new */
}

.message-bubble.message-new {
    animation: messageAppear 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    will-change: transform, opacity;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.93);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Send button pulse on tap */
.chat-send-btn.sending {
    animation: sendPulse 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes sendPulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(0.82); }
    100% { transform: scale(1); }
}

.message-sent {
    align-self: flex-end;
    background: linear-gradient(135deg, #0b7d62, #20a58a);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-received {
    align-self: flex-start;
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message-timestamp {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message-received .message-timestamp {
    color: #64748b;
}

.message-sent .message-timestamp {
    color: rgba(255, 255, 255, 0.9);
}

/* =========================
   Message Input - FIXED
   ========================= */
.chat-input-container {
    flex-shrink: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 45;
}

.chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    padding: 12px 16px;
}

.chat-input-container > * {
    pointer-events: auto;
}

/* =========================
   Chat Reply Preview (WhatsApp-style, shown above composer
   while composing — before send)
   ========================= */
.chat-reply-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    /* Right margin = send-btn (40px) + row gap (10px) + row's own right
       padding (16px) = 66px, so this card's right edge lines up exactly
       with the chat-input-wrapper's right edge below it, instead of
       running underneath the send button. */
    margin: 8px 66px 0 16px;
    padding: 10px 12px;
    background: #ffffff;
    border-radius: 12px;
    border-left: 3px solid #0b7d62;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    max-height: 64px;
    opacity: 1;
    transition: max-height 0.22s ease, opacity 0.16s ease,
                margin 0.22s ease, padding 0.22s ease, box-shadow 0.22s ease;
}

.chat-reply-preview.chat-reply-preview-hidden {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-left-width: 0;
    box-shadow: none;
    pointer-events: none;
    /* left/right margin intentionally left untouched — only collapses vertically */
}

.chat-reply-preview-content {
    flex: 1;
    min-width: 0;
}

.chat-reply-preview-title {
    font-weight: 700;
    font-size: 13.5px;
    color: #0b7d62;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-reply-preview-detail {
    font-size: 12.5px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-reply-preview-close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #94a3b8;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-reply-preview-close:active {
    background: #e2e8f0;
    color: #64748b;
}

/* Extra scroll clearance so the last message isn't hidden behind the taller
   fixed input bar when the reply preview row is showing */
.chat-messages.has-reply-preview {
    /* no extra clearance needed: the composer is in normal flow now */
}

/* =========================
   Message Input - FIXED
   ========================= */
.chat-input-wrapper {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    min-height: 40px;
    max-height: 120px;
    display: flex;
    align-items: center;
    transition: all 0.2s ease;
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    color: #1e293b;
    resize: none;
    max-height: 100px;
    min-height: 40px;
    line-height: 1.4;
    outline: none;
    font-family: inherit;
    padding: 9px 16px;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-input:focus {
    outline: none;
    box-shadow: none;
}

.chat-input::placeholder {
    color: #94a3b8;
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0b7d62, #20a58a);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(11, 125, 98, 0.3);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* =========================
   Conversation List (Inbox)
   ========================= */
.conversations-list {
    background: white;
}

.conversation-item {
    display: flex;
    padding: 14px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.2s ease;
    align-items: flex-start;
    gap: 0; /* Changed from 12px to remove gap */
}

.conversation-item:hover {
    background: #f8fafc;
}

.conversation-item.pressing {
    background: #eef2f7;
}

.conversation-avatar {
    display: none; /* Hide the avatar */
}

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

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.conversation-title {
    font-weight: 700;
    color: #1e293b;
    font-size: 15px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.conversation-time {
    font-size: 12px;
    color: #94a3b8;
    flex-shrink: 0;
    margin-left: 8px;
}

.conversation-time-wrap {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: 8px;
}

.conversation-time-wrap .conversation-time {
    margin-left: 0;
}

.conversation-preview {
    font-size: 14px;
    color: #64748b;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.conversation-unread {
    background: #ef4444;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    flex-shrink: 0;
    align-self: center;
}

/* =========================
   Empty States
   ========================= */
.empty-conversations {
    text-align: center;
    padding: 48px 20px;
    color: #64748b;
}

.empty-conversations-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-conversations h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1e293b;
}

.empty-conversations p {
    font-size: 14px;
    line-height: 1.5;
    max-width: 300px;
    margin: 0 auto;
}

/* =========================
   Account Tabs with Page Indicator
   ========================= */
/* Compact floating tabs - outside card container */
.account-tabs-indicator {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 2px 0; /* 🔥 tighter */
    background: transparent;
}

.indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: background 0.3s ease;
}

.indicator-dot.active {
    background: #0b7d62;
    transform: scale(1.2);
}

.account-tabs-scroll {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0; /* 🔥 IMPORTANT: removes gap */
}

.account-tabs-scroll::-webkit-scrollbar {
    display: none;
}

.account-tab-btn-enhanced {
    padding: 10px 16px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.account-tab-btn-enhanced:hover {
    color: #0b7d62;
}

.account-tab-btn-enhanced.active {
    color: #0b7d62;
}

.account-tab-btn-enhanced.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: #0b7d62;
    border-radius: 2px 2px 0 0;
}

.tab-count-badge {
    background: #0b7d62;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 6px;
}

.tab-count-badge.unread {
    background: #ef4444;
}

/* Make account tabs behave like a fixed header */
.account-tabs-scroll {
    position: sticky;
    top: 0;
    z-index: 40; /* Changed from 20 - below chat-header, above content */
    background: white;
    border-bottom: 1px solid #e5e7eb;
}

/* =========================
   Chat Screen (Full Screen)
   ========================= */
.chat-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100dvh; /* Dynamic viewport height - adjusts for keyboard */
    background: white;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    animation: slideInUp 0.3s ease;
    overflow: hidden;
}

@keyframes slideInUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.chat-screen-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: white;
    position: sticky;
    top: 0;
    z-index: 50; /* Ensure it stays on top within chat screen */
}

.chat-back-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-back-btn:hover {
    background: #e2e8f0;
    transform: scale(1.05);
}

.chat-header-title {
    flex: 1;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
}

/* =========================
   Responsive Adjustments
   ========================= */
@media (max-width: 640px) {
    .chat-header {
        padding: 12px;
    }
    
    .chat-messages {
        padding: 12px;
    }
    
    .message-bubble {
        max-width: 85%;
    }
    
    .conversation-item {
        padding: 12px;
    }
    
    .conversation-avatar {
        width: 40px;
        height: 40px;
        font-size: 14px;
    }
    
    .account-tabs-scroll {
        padding: 0 12px;
    }
    
    .account-tab-btn-enhanced {
        padding: 12px 14px;
        font-size: 14px;
    }
}

/* Force 2 tabs per viewport width */
.account-tab-btn-enhanced {
    flex: 0 0 50%;
    text-align: center;
}

/* Tighten spacing under Account header card */
#account .card {
    margin-bottom: 6px; /* was likely 16px+ */
}

/* Pull tabs closer to dots */
.account-tabs-scroll {
    margin-top: 0;
}

/* DEBUG: remove spacing coming from acctState content */
#acctState > *:last-child {
    margin-bottom: 0 !important;
}


/* Pull My Posts section closer to Account header */
#myPostsContainer {
    margin-top: -12px;
}

/* ===========================================
   FIXES FOR REQUIREMENTS 1, 3, 4
   =========================================== */

/* 1. FIX SPACING - Equal distance between cards and dots */
.account-tabs-indicator {
    padding: 1px 0 8px 0; /* 1px top, 8px bottom */
    margin: 0;
    background: transparent;
}

#account .card + .account-tabs-indicator {
    margin-top: 0; /* Remove negative margin */
}

.account-tabs-indicator + #myPostsContainer {
    margin-top: 0; /* Remove negative margin */
}

/* Proper spacing between Account header and dots */
#account > .card:first-child {
    margin-bottom: 12px; /* Space before dots */
}

/* 3. INCREASE TAB FONT SIZE - Match original */
.account-tab-btn-enhanced {
    padding: 12px 16px;
    background: none;
    border: none;
    font-size: 16px; /* Increased from 14px */
    font-weight: 600;
    color: #64748b;
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

/* 4. SUBTLE GREEN HIGHLIGHT - Active tab background */
.account-tab-btn-enhanced.active {
    color: #0b7d62;
    background: rgba(11, 125, 98, 0.08); /* Subtle mint green tint */
    border-radius: 8px 8px 0 0;
}

.account-tab-btn-enhanced.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px; /* Slightly thicker */
    background: #0b7d62;
    border-radius: 2px 2px 0 0;
}

/* Ensure tabs maintain proper width when visibility changes */
.account-tab-btn-enhanced {
    flex: 0 0 50%;
    text-align: center;
}

/* Smooth transitions when tabs show/hide */
.account-tabs-scroll {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
    transition: all 0.3s ease;
}

.msg-status {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.7;
}

.msg-failed {
    color: #ef4444;
    opacity: 1;
}

/* Status indicators for optimistic UI */
.msg-status {
    margin-left: 4px;
    font-size: 11px;
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.msg-failed {
    color: #ef4444;
    opacity: 1;
    font-weight: 600;
}

.msg-status-read {
    color: #34b7f1; /* WhatsApp-style blue */
    opacity: 1;
}

.msg-ticks {
    width: 16px;
    height: 11px;
    display: block;
}

/* Date separators in chat */
.chat-date-separator {
    text-align: center;
    font-size: 12px;
    color: #94a3b8;
    margin: 16px 0 12px 0;
    position: relative;
}

.chat-date-separator::before,
.chat-date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 35%;
    height: 1px;
    background: #e2e8f0;
}

.chat-date-separator::before {
    left: 0;
}

.chat-date-separator::after {
    right: 0;
}

/* =========================
   Prevent Background Scroll
   ========================= */
body.chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

.chat-screen {
    overflow: hidden; /* Add to existing .chat-screen rules */
}

/* =========================
   Prevent Messages Tab Scroll When Chat Open
   ========================= */
#messagesTabContent.chat-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Also prevent body scroll as backup */
body.chat-open {
    overflow: hidden;
}

.chat-screen {
    overflow: hidden;
}

/* =========================
   Message Context Cards (Listing Metadata)
   ========================= */
.message-context {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 6px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

.message-received .message-context {
    background: #f1f5f9;
    border-left-color: #0b7d62;
}

.message-context-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.message-context-content {
    flex: 1;
    min-width: 0;
}

.message-context-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 2px;
}

.message-context-route,
.message-context-location {
    font-size: 11px;
    opacity: 0.8;
    margin-bottom: 2px;
}

.message-context-price {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

.message-sent .message-context {
    color: white;
}

.message-received .message-context-title {
    color: #1e293b;
}

.message-received .message-context-route,
.message-received .message-context-location {
    color: #64748b;
}

.message-received .message-context-price {
    color: #0b7d62;
}

/* =========================
   Hub Nav Notification Dot
   ========================= */
.hub-notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 4px;
    background: #ef4444;
    border-radius: 50%;
}

.tab-icon {
    position: relative;
}

/* Inline notification dot — sits beside text, not corner-anchored */
.hub-tab-label-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hub-dot-inline {
    width: 4px;
    height: 4px;
    background: #ef4444;
    border-radius: 50%;
    flex-shrink: 0;
}

/* More button: dot sits after the arrow */
.hub-dot-slot {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}
#hubMoreDot {
    width: 4px;
    height: 4px;
    margin-left: -4px;
    position: relative;
    top: -4px;
}

/* =========================
   Loads Simple Text Display
   ========================= */
.loads-text-bubble {
    align-self: flex-start;
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    max-width: 85%;
    padding: 10px 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
    animation: messageAppear 0.2s ease-out;
}

.loads-text-bubble a.load-phone-inline {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.loads-text-bubble a.load-phone-inline:active {
    text-decoration: underline;
}

.loads-card-group {
    display: flex;
    flex-direction: column;
    align-self: flex-start;
    max-width: 85%;
}

.loads-action-row {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 4px;
    width: 100%;
}

/* Base style — both buttons equal width, unified grey */
.loads-action-row .load-action-btn {
    flex: 1;
    padding: 11px 18px;
    border-radius: 14px;
    border: 1px solid #e2e8f0 !important;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #f3f4f6 !important;
    color: #374151 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* MORE — no change needed, inherits base */
.loads-action-row .load-action-btn[data-action="load-more"]:hover {
    background: #e9ebee;
    border-color: #d1d5db;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

/* SET ALERT — unified grey, slightly distinguishable */
.loads-action-row .load-action-btn[data-action="set-alert"] {
    background: #eaecef !important;
    color: #1f2937 !important;
    border-color: #d1d5db !important;
}

.loads-action-row .load-action-btn[data-action="set-alert"]:hover {
    background: #e2e5e9;
    border-color: #c4c9d1;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}

.loads-action-row .load-action-btn:active {
    transform: scale(0.97);
    box-shadow: none;
}

.loads-action-row .load-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =========================
   Paywall CTA Block
   ========================= */
.loads-paywall {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 14px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    margin-top: 8px;
}

.loads-paywall .paywall-remaining {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 2px;
}

.loads-paywall .paywall-privacy {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 4px;
}

.loads-paywall .paywall-cta-text {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 10px;
}

.loads-paywall .paywall-subscribe-btn {
    width: 100%;
    padding: 12px 18px;
    border-radius: 14px;
    border: none !important;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0b7d62, #20a58a) !important;
    color: white !important;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(11, 125, 98, 0.3);
    transition: all 0.2s ease;
    flex: unset;
}

.loads-paywall .paywall-subscribe-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 125, 98, 0.4);
}

/* ===========================
   Alert Limit Banner (non-subscribers at cap)
   =========================== */

.alerts-limit-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
    padding: 12px 14px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.alerts-limit-text {
    font-size: 13px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

.alerts-limit-cta {
    flex-shrink: 0;
    background: linear-gradient(135deg, #0b7d62, #20a58a);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(11, 125, 98, 0.3);
    transition: all 0.2s ease;
    display: inline-block;
}

.alerts-limit-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 125, 98, 0.4);
}

.alerts-limit-cta:active {
    transform: scale(0.97);
}

@media (prefers-color-scheme: dark) {
    .alerts-limit-banner {
        background: #2a2a2c;
        border-color: #3f3f41;
    }

    .alerts-limit-text {
        color: #9ca3af;
    }
}

/* =========================
   Invoice Summary Card
   ========================= */
.invoice-summary-card {
    align-self: flex-start;
    background: white;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #0b7d62;
    border-radius: 14px;
    padding: 14px 16px;
    width: 85%;
    max-width: 85%;
    flex: 0 0 auto;
    box-sizing: border-box;
    transform: translateZ(0);
    backface-visibility: hidden;
    will-change: transform, opacity;
    animation: none;
}

.invoice-summary-title {
    font-size: 13px;
    font-weight: 700;
    color: #0b7d62;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 10px;
}

.invoice-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    font-size: 13px;
    padding: 5px 0;
    border-bottom: 1px solid #f1f5f9;
}

.invoice-summary-row:last-of-type {
    border-bottom: none;
}

.invoice-summary-row span:first-child {
    color: #94a3b8;
    flex-shrink: 0;
    font-size: 12px;
}

.invoice-summary-row span:last-child {
    color: #1e293b;
    font-weight: 500;
    text-align: right;
}

.invoice-summary-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.invoice-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.invoice-btn-confirm {
    background: linear-gradient(135deg, #0b7d62, #20a58a);
    color: white;
    box-shadow: 0 2px 8px rgba(11, 125, 98, 0.3);
}

.invoice-btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 125, 98, 0.4);
}

.invoice-btn-edit {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e2e8f0;
}

.invoice-btn-edit:hover {
    background: #e9ebee;
}

.invoice-btn:active {
    transform: scale(0.97);
}

@media (prefers-color-scheme: dark) {
    .invoice-summary-card {
        background: #2a2a2c;
        border-color: #3f3f41;
        border-left-color: #0b7d62;
    }

    .invoice-summary-title {
        color: #4caf82;
    }

    .invoice-summary-row {
        border-bottom-color: #3f3f41;
    }

    .invoice-summary-row span:first-child {
        color: #6b7280;
    }

    .invoice-summary-row span:last-child {
        color: #e5e7eb;
    }

    .invoice-btn-edit {
        background: #3f3f41;
        color: #e5e7eb;
        border-color: #52525b;
    }
}

/* =========================
   Afi Task Chips
   ========================= */
.afi-task-chip {
    background: linear-gradient(135deg, #ffffff, #f0fdf4);
    border: 1.5px solid #0b7d62;
    border-radius: 24px;
    padding: 13px 18px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0b7d62;
    text-align: left;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(11, 125, 98, 0.15),
                0 1px 3px rgba(11, 125, 98, 0.1);
}

.afi-task-chip:active {
    background: #f0fdf4;
    transform: scale(0.97);
    box-shadow: 0 1px 4px rgba(11, 125, 98, 0.1);
}

.afi-task-chip svg {
    flex-shrink: 0;
    color: #0b7d62;
}

/* =========================
   Animated Loading Dots
   ========================= */
@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

.afi-dot {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    margin: 0 2px;
    vertical-align: middle;
    animation: dotPulse 1.4s infinite ease-in-out;
}

.afi-dot:nth-child(2) { animation-delay: 0.2s; }
.afi-dot:nth-child(3) { animation-delay: 0.4s; }

/* Native Android: the status bar is hidden in these screens, so no clearance is needed */
html.is-native .chat-screen-header,
html.is-native .invoice-preview-header {
    padding-top: 25px !important;
}

/* Native iOS: keep clearing the notch / Dynamic Island */
@supports (-webkit-touch-callout: none) {
    html.is-native .chat-screen-header,
    html.is-native .invoice-preview-header {
        padding-top: calc(env(safe-area-inset-top, 0px) + 14px) !important;
    }
}

/* Chat header ⋮ menu */
.chat-screen-header .chat-header-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap; /* long names can't push the ⋮ off screen */
}
.chat-menu-wrap { position: relative; flex-shrink: 0; }
.chat-menu-btn {
    width: 40px; height: 40px; border-radius: 50%; border: none;
    background: transparent; color: #64748b; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
}
.chat-menu-btn:active { background: #f1f5f9; }
.chat-menu-divider { height: 1px; margin: 4px 0; background: rgba(128,128,128,.25); }
.chat-menu-popover {
    position: absolute; top: calc(100% + 4px); right: 0;
    min-width: 180px; padding: 6px; z-index: 60;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    transform-origin: top right;
    transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.2, 0.9, 0.3, 1), visibility 0.16s;
}
.chat-menu-hidden {
    opacity: 0;
    transform: scale(0.85);
    visibility: hidden;
    pointer-events: none;
}
.chat-menu-item {
    display: block; width: 100%; text-align: left;
    padding: 12px 14px; border: none; border-radius: 8px;
    background: transparent; font-size: 15px; color: #1e293b; cursor: pointer;
}
.chat-menu-item:active { background: #f1f5f9; }
.chat-menu-item-danger { color: #b91c1c; }
.chat-menu-divider { height: 1px; margin: 4px 6px; background: #e5e7eb; }

/* Composer when you've blocked this user */
.chat-input:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}
.chat-input:disabled::placeholder { color: #94a3b8; }

/* ===== Telegram-style chat (scoped to the user chat overlay) ===== */

/* Wallpaper */
.tg-chat .chat-container {
    background: linear-gradient(165deg, #e6f1ec 0%, #f1f6ee 55%, #e4eee9 100%);
}

/* Messages + bubbles */
.tg-chat .chat-messages { gap: 8px; padding: 12px 10px; }
.tg-chat .message-bubble {
    font-size: 15px;
    padding: 7px 11px 6px;
    border-radius: 18px;
    max-width: 80%;
}
.tg-chat .message-timestamp {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 3px;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1;
}
.tg-chat .msg-status { margin-left: 0; }

/* Grouping: same sender back to back sits 2px apart */
.tg-chat .message-sent + .message-sent,
.tg-chat .message-received + .message-received { margin-top: -6px; }
.tg-chat .message-sent + .message-sent { border-top-right-radius: 4px; }
.tg-chat .message-received + .message-received { border-top-left-radius: 4px; }

/* Date pill */
.tg-chat .chat-date-separator {
    align-self: center;
    margin: 8px 0 4px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.28);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
}
.tg-chat .chat-date-separator::before,
.tg-chat .chat-date-separator::after { display: none; }

/* Header */
.tg-chat .chat-screen-header { padding: 8px 12px; gap: 8px; }
.tg-chat .chat-back-btn { background: transparent; }
.tg-chat .chat-back-btn:hover { background: rgba(128, 128, 128, 0.15); transform: none; }
.chat-header-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-header-avatar {
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
    background: linear-gradient(135deg, #0b7d62, #20a58a);
    color: #fff; font-size: 17px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.chat-header-text { min-width: 0; flex: 1; }
.tg-chat .chat-header-title { flex: none; padding: 0; margin: 0; line-height: 1.2; }
.chat-header-status { font-size: 12px; color: #64748b; line-height: 1.3; margin-top: 1px; }

/* Floating input pill */
.tg-chat .chat-input-container { background: transparent; border-top: none; }
.tg-chat .chat-input-wrapper {
    background: #fff;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    padding-right: 4px;
}
.chat-attach-btn {
    width: 36px; height: 36px; border: none; border-radius: 50%;
    background: transparent; color: #94a3b8; cursor: pointer;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-attach-btn[hidden] { display: none; }

@media (prefers-color-scheme: dark) {
    .tg-chat .chat-container {
        background: linear-gradient(165deg, #12161b 0%, #16201f 55%, #11181a 100%);
    }
    .tg-chat .chat-date-separator { background: rgba(255, 255, 255, 0.12); color: #cbd5e1; }
    .chat-header-status { color: #9ca3af; }
    .tg-chat .chat-input-wrapper { background: #252933; box-shadow: none; }
}

.chat-call-btn { flex-shrink: 0; }
.chat-call-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Photo messages ===== */
.chat-attach-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.tg-chat .message-has-image { padding: 3px; }
.message-image {
    position: relative;
    width: 240px;
    max-width: 100%;
    max-height: 320px;
    border-radius: 15px;
    overflow: hidden;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.08);
}
.message-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tg-chat .message-has-image .message-timestamp {
    position: absolute;
    right: 9px;
    bottom: 8px;
    margin: 0;
    padding: 3px 7px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    opacity: 1;
}
.message-image.is-uploading img { opacity: 0.55; }
.message-image.is-uploading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: chatImgSpin 0.8s linear infinite;
}
@keyframes chatImgSpin { to { transform: rotate(360deg); } }

.chat-lightbox {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ===== Photo captions ===== */
.message-caption {
    padding: 6px 8px 0;
    font-size: 15px;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
    min-width: 0;
}
/* With a caption, the time sits under the text instead of over the photo */
.tg-chat .message-has-image.message-has-caption .message-timestamp {
    position: static;
    margin: 2px 0 0;
    padding: 0 6px 2px 0;
    background: none;
    color: inherit;
    opacity: 0.7;
}

/* Full-screen preview with caption box */
.chat-img-preview {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: #000;
    display: flex;
    flex-direction: column;
}
.chat-img-preview-close {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    left: 12px;
    z-index: 1;
    width: 40px; height: 40px;
    border: none; border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff; font-size: 26px; line-height: 1;
    cursor: pointer;
}
.chat-img-preview-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-img-preview-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.chat-img-preview-bar {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: rgba(0, 0, 0, 0.6);
}
.chat-img-preview-caption {
    flex: 1;
    min-width: 0;
    max-height: 120px;
    resize: none;
    border: none;
    outline: none;
    border-radius: 20px;
    padding: 10px 14px;
    font: inherit;
    font-size: 15px;
    background: #252933;
    color: #fff;
}
.chat-img-preview-caption::placeholder { color: #94a3b8; }
.chat-img-preview-send {
    width: 40px; height: 40px;
    flex-shrink: 0;
    border: none; border-radius: 50%;
    background: #0b7d62;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

/* ===== Document (PDF) messages ===== */
.tg-chat .chat-input { min-width: 0; }
.tg-chat .message-has-file { padding: 7px 10px 6px; }
.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    max-width: 260px;
    cursor: pointer;
}
.message-file-icon {
    position: relative;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}
.message-received .message-file-icon { background: rgba(11, 125, 98, 0.12); color: #0b7d62; }
.message-file-info { min-width: 0; flex: 1; }
.message-file-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.message-file-meta { font-size: 12px; opacity: 0.75; margin-top: 1px; }
.message-file.is-uploading .message-file-icon svg { opacity: 0; }
.message-file.is-uploading .message-file-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2.5px solid rgba(255, 255, 255, 0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: chatImgSpin 0.8s linear infinite;
}
.message-received .message-file.is-uploading .message-file-icon::after {
    border-color: rgba(11, 125, 98, 0.25);
    border-top-color: #0b7d62;
}

/* ===== PDF preview card (WhatsApp-style) ===== */
.tg-chat .message-has-preview { padding: 3px 3px 5px; }
.message-file.has-preview { display: block; width: 240px; min-width: 0; max-width: 100%; }
.message-file-preview {
    position: relative;
    height: 150px;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    background: #fff;
}
.message-file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
}
.message-file.has-preview .message-file-info {
    padding: 8px 10px 9px;
    border-radius: 0 0 12px 12px;
    background: rgba(0, 0, 0, 0.14);
}
.message-received .message-file.has-preview .message-file-info { background: #eef2f6; }
.message-file.has-preview .message-file-name { font-size: 15px; font-weight: 500; }
.message-file.has-preview .message-file-meta { font-size: 13px; }
.tg-chat .message-has-preview .message-timestamp { padding: 3px 6px 0 0; }
.message-file.has-preview.is-uploading .message-file-preview img { opacity: 0.6; }
.message-file.has-preview.is-uploading .message-file-preview::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid rgba(0, 0, 0, 0.15);
    border-top-color: #0b7d62;
    border-radius: 50%;
    animation: chatImgSpin 0.8s linear infinite;
}
@media (prefers-color-scheme: dark) {
    .message-received .message-file.has-preview .message-file-info { background: #1c1f26; }
}

/* ===== Voice notes ===== */
.chat-send-btn .icon-mic { display: none; }
.chat-send-btn.is-mic .icon-mic { display: block; }
.chat-send-btn.is-mic .icon-send { display: none; }

.chat-record-bar { display: none; }
.chat-input-row.is-recording .chat-input-wrapper { display: none; }
.chat-input-row.is-recording .chat-record-bar {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 0 6px;
    border-radius: 24px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.chat-record-cancel {
    width: 36px; height: 36px; flex-shrink: 0;
    border: none; border-radius: 50%;
    background: transparent; color: #ef4444; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.chat-record-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #ef4444;
    animation: chatRecPulse 1s ease-in-out infinite;
}
.chat-record-time { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; color: #1e293b; }
.chat-record-hint { font-size: 13px; color: #94a3b8; }
@keyframes chatRecPulse { 50% { opacity: 0.25; } }

.tg-chat .message-has-voice { padding: 8px 10px 6px; }
.message-voice {
    display: flex; align-items: center; gap: 10px;
    min-width: 210px; max-width: 250px; cursor: pointer;
}
.voice-play {
    width: 38px; height: 38px; flex-shrink: 0; padding: 0;
    border: none; border-radius: 50%; cursor: pointer;
    background: rgba(255, 255, 255, 0.25); color: #fff;
    display: flex; align-items: center; justify-content: center;
}
.message-received .voice-play { background: #0b7d62; }
.voice-play .icon-pause { display: none; }
.message-voice.is-playing .icon-pause { display: block; }
.message-voice.is-playing .icon-play { display: none; }
.voice-wave { flex: 1; min-width: 0; height: 26px; display: flex; align-items: center; gap: 2px; }
.voice-wave i { flex: 1; min-height: 3px; border-radius: 2px; position: relative; }
.voice-wave i::before,
.voice-wave i::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background: currentColor;
}
.voice-wave i::before { opacity: 0.4; }
/* Solid layer is revealed left to right by --f (0 to 1), set every frame by the player */
.voice-wave i::after { clip-path: inset(0 calc((1 - var(--f, 0)) * 100%) 0 0); }
.voice-time { flex-shrink: 0; font-size: 12px; opacity: 0.8; font-variant-numeric: tabular-nums; }
.message-voice.is-uploading .voice-wave { animation: chatRecPulse 1s ease-in-out infinite; }
.voice-play { transition: transform 0.12s ease; }
.voice-play:active { transform: scale(0.92); }


@media (prefers-color-scheme: dark) {
    .chat-input-row.is-recording .chat-record-bar { background: #252933; box-shadow: none; }
    .chat-record-time { color: #f0f2f5; }
}

/* ===== Telegram-style chat list ===== */
.conversations-list .conversation-item {
    align-items: center;
    gap: 10px;
    padding: 0 8px;
    border-bottom: none;
}
.conversations-list .conversation-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    margin: 9px 0;
    border-radius: 50%;
    flex-shrink: 0;
    color: #fff;
    font-size: 19px;
    font-weight: 600;
}
.conversations-list .conversation-content {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 9px 0;
    border-bottom: 1px solid #f1f5f9;
}
.conversations-list .conversation-item:last-child .conversation-content { border-bottom: none; }
.conversations-list .conversation-header { align-items: baseline; margin-bottom: 3px; }
.conversations-list .conversation-title { font-size: 15px; font-weight: 600; }
.conversations-list .conversation-time { font-size: 11px; }
.conversation-footer { display: flex; align-items: center; gap: 8px; }
.conversation-footer .conversation-preview { flex: 1; min-width: 0; -webkit-line-clamp: 1; font-size: 13px; }
.conversation-you { color: #0b7d62; }
.conversation-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #0b7d62;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.conversations-list .conversation-item.is-unread .conversation-title { font-weight: 700; }
.conversations-list .conversation-item.is-unread .conversation-time { color: #0b7d62; }
.empty-conversations-icon::before { content: '💬'; }

@media (prefers-color-scheme: dark) {
    .conversations-list .conversation-content { border-bottom-color: #2d3140; }
    .conversation-you { color: #20a58a; }
    .conversation-badge { background: #20a58a; }
    .conversations-list .conversation-item.is-unread .conversation-time { color: #20a58a; }
}

@media (hover: none) {
    .conversations-list .conversation-item:hover { background: transparent; }
    .conversations-list .conversation-item.pressing { background: rgba(128, 128, 128, 0.12); }
}

/* ===== Afi chat polish ===== */
.afi-header-avatar svg { display: block; }
#afiChatScreen .message-bubble > div:first-child { white-space: pre-wrap; }
.message-text { white-space: pre-wrap; word-break: break-word; }
.afi-typing { padding: 12px 14px; }
.afi-typing .afi-dot { width: 7px; height: 7px; margin: 0 2px; }
.afi-task-chip {
    width: auto;
    padding: 9px 14px;
    font-size: 14px;
    border-radius: 20px;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(11, 125, 98, 0.12);
}
.afi-task-chip svg { width: 16px; height: 16px; }

/* ===== Danai card grid: chips laid out 2 per row ===== */
.afi-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 4px 10px 12px;
}
.afi-card-grid .afi-task-chip {
    width: 100%;
    min-width: 0;
    height: 44px;
    padding: 0 14px;
    line-height: 1;
}
.afi-chip-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== My Trucks modal ===== */
.mt-screen {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; height: 100dvh;
    background: #f8fafc; z-index: 1050;
    display: flex; flex-direction: column;
    animation: slideInUp 0.3s ease;
}
.mt-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 700; color: #1e293b; }
.mt-body { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; }
.mt-footer {
    display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: #fff; border-top: 1px solid #e5e7eb;
}
.mt-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px; margin-bottom: 8px; text-align: left; cursor: pointer;
    background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
    -webkit-tap-highlight-color: transparent;
}
.mt-row:active { background: #f1f5f9; }
.mt-row-icon {
    width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%;
    background: rgba(11, 125, 98, 0.1); color: #0b7d62;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.mt-row-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mt-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mt-row-reg { font-size: 15px; font-weight: 700; color: #1e293b; }
.mt-row-sub { font-size: 13px; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-row-chev { font-size: 22px; color: #cbd5e1; }
.mt-empty { text-align: center; padding: 48px 20px; color: #64748b; font-size: 14px; line-height: 1.6; }
.mt-field { display: block; margin-bottom: 14px; }
.mt-field span { display: block; margin-bottom: 4px; font-size: 12px; color: #64748b; }
.mt-field input {
    width: 100%; box-sizing: border-box; padding: 12px 14px;
    font-size: 16px; color: #1e293b; background: #fff;
    border: 1px solid #e2e8f0; border-radius: 12px; outline: none; font-family: inherit;
}
.mt-field input:focus { border-color: #0b7d62; }
.mt-field input:disabled { background: #f1f5f9; color: #94a3b8; }
.mt-section { margin: 20px 0 6px; font-size: 12px; font-weight: 700; color: #0b7d62; text-transform: uppercase; letter-spacing: 0.05em; }
.mt-link { padding: 10px; font-size: 12px; word-break: break-all; color: #0b7d62; background: #f0fdf4; border-radius: 10px; }
.mt-actions { display: flex; gap: 8px; margin-top: 8px; }
.mt-actions a.invoice-btn, .mt-gate-btn { display: block; text-align: center; text-decoration: none; box-sizing: border-box; }
#mtBody .mt-gate-btn { display: block !important; width: calc(100% - 24px) !important; margin: 24px 12px 0 !important; padding: 14px 20px; text-align: center; box-sizing: border-box; }
.mt-danger {
    width: 100%; margin-top: 24px; padding: 12px; font-size: 14px; font-weight: 600;
    color: #b91c1c; background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; cursor: pointer;
}
.mt-added-title { font-size: 17px; font-weight: 700; color: #1e293b; margin-bottom: 6px; }
.mt-added-text { font-size: 14px; color: #64748b; line-height: 1.5; margin-bottom: 12px; }
@media (prefers-color-scheme: dark) {
    .mt-screen { background: #12161b; }
    .mt-title, .mt-row-reg, .mt-added-title { color: #f0f2f5; }
    .mt-footer { background: #1c1f26; border-top-color: #2d3140; }
    .mt-row, .mt-field input { background: #252933; border-color: #2d3140; color: #f0f2f5; }
    .mt-field input:disabled { background: #1c1f26; }
    .mt-link { background: rgba(32, 165, 138, 0.12); color: #20a58a; }
    .mt-danger { background: rgba(185, 28, 28, 0.15); border-color: rgba(185, 28, 28, 0.4); color: #f87171; }
}

/* Photos fill the circle */
.conversations-list .conversation-avatar,
.chat-header-avatar, .profile-avatar, .ep-avatar { overflow: hidden; }
.conversations-list .conversation-avatar img,
.chat-header-avatar img, .profile-avatar img, .ep-avatar img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}

/* Settings header */
.profile-avatar {
    width: 48px; height: 48px; flex: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0b7d62, #20a58a);
    color: #fff; font-size: 18px; font-weight: 700;
}

/* Edit Profile picker */
.ep-avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 14px; }
.ep-avatar {
    position: relative; width: 88px; height: 88px; border-radius: 50%;
    border: 0; padding: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 34px; font-weight: 700;
}
.ep-avatar::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 30%;
    background: rgba(0,0,0,.38) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.ep-avatar-remove { background: none; border: 0; color: #b42318; font-size: .85rem; cursor: pointer; padding: 4px 8px; }

/* ===== Pinned next-step strip (under the chat header) ===== */
.next-step-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    padding: 8px 12px;
    background: #fff;
    border-left: 3px solid #0b7d62;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.next-step-label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.next-step-buttons { display: flex; gap: 8px; }

/* Chat card: stacked, full width */
.invoice-load-actions { flex-direction: column; }
.invoice-load-actions .btn.small { width: 100%; padding: 12px 16px; font-size: 15px; }
.invoice-load-actions .inv-cancel {
    background: none; border: 0; box-shadow: none;
    color: #64748b; font-weight: 600; padding: 8px;
}

/* Pinned strip: one line, 2 : 1 */
.next-step-buttons .inv-main   { flex: 2 1 0; min-width: 0; white-space: nowrap; }
.next-step-buttons .inv-cancel { flex: 1 1 0; min-width: 0; white-space: nowrap; }

@media (prefers-color-scheme: dark) {
    .next-step-bar {
        background: #1c2128;
        border-bottom-color: rgba(255, 255, 255, 0.08);
    }
    .next-step-label { color: #cbd5e1; }
}

/* The pinned strip replaces these card buttons while it is showing */
.action-pinned { display: none !important; }

.sub-alt{display:block;width:100%;margin-top:10px;padding:10px;border:0;background:none;color:var(--brand,#0b7d62);font-size:14px;font-weight:600;cursor:pointer}
.sub-paste{margin-top:6px}
.sub-paste[hidden]{display:none}
.sub-paste textarea{width:100%;box-sizing:border-box;padding:12px;margin-bottom:10px;border:1.5px solid var(--line,#e5e7eb);border-radius:12px;background:transparent;color:inherit;font:inherit;font-size:14px;resize:none}
.sub-paste textarea:focus{outline:2px solid var(--brand,#0b7d62);outline-offset:0}
.mt-screen .mt-gate-btn{display:block;width:calc(100% - 48px);max-width:360px;margin:24px auto 0;padding:14px 20px;border:0;font-size:15px;font-weight:700;text-align:center;cursor:pointer}

/* =========================
   Reply (quote), swipe, delete for everyone
   ========================= */
.chat-overlay.tg-chat .message-bubble[data-msg-id] {
    touch-action: pan-y;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Swipe-to-reply arrow that trails the bubble */
.message-bubble.is-swiping { z-index: 1; will-change: transform; }
.message-bubble.is-swiping::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -44px;
    width: 32px;
    height: 32px;
    margin-top: -16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b7d62' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 14 4 9 9 4'/%3E%3Cpath d='M20 20v-7a4 4 0 0 0-4-4H4'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    opacity: var(--swipe-p, 0);
    transform: scale(calc(0.6 + 0.4 * var(--swipe-p, 0)));
}

/* Quote shown inside a bubble */
.message-quote {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin: 0 0 6px;
    padding: 5px 8px;
    border-left: 3px solid #0b7d62;
    border-radius: 8px;
    background: rgba(11, 125, 98, 0.1);
    cursor: pointer;
    overflow: hidden;
}
.message-sent .message-quote {
    border-left-color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.16);
}
.message-quote-body { flex: 1; min-width: 0; }
.message-quote-author { font-size: 12.5px; font-weight: 700; color: #0b7d62; }
.message-sent .message-quote-author { color: #fff; }
.message-quote-text {
    font-size: 13px;
    opacity: 0.85;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.message-quote-thumb {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Deleted message */
.message-deleted .message-deleted-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-style: italic;
    opacity: 0.75;
}
.message-deleted .message-deleted-text svg { flex-shrink: 0; }

/* Highlight when jumping to a quoted message */
.message-bubble.message-flash { animation: messageFlash 1.1s ease; }
@keyframes messageFlash {
    0%, 100% { box-shadow: 0 0 0 0 rgba(11, 125, 98, 0); }
    30% { box-shadow: 0 0 0 4px rgba(11, 125, 98, 0.35); }
}

/* Long-press menu */
.chat-action-sheet {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1200;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}
.chat-action-panel {
    width: 100%;
    max-width: 480px;
    background: #fff;
    border-radius: 16px 16px 0 0;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom, 0px));
}
.chat-action-item {
    display: block;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: transparent;
    text-align: left;
    font-size: 16px;
    color: #1e293b;
    border-radius: 10px;
    cursor: pointer;
}
.chat-action-item:active { background: #f1f5f9; }
.chat-action-danger { color: #dc2626; }

@media (prefers-color-scheme: dark) {
    .chat-action-panel { background: #1c1f26; }
    .chat-action-item { color: #e2e8f0; }
    .chat-action-item:active { background: #2d3140; }
    .chat-action-danger { color: #f87171; }
    .message-received .message-quote-author { color: #20a58a; }
}