/* ============================================================
   Components - Buttons, Cards, Inputs, Lists, Badges, etc.
   ============================================================ */


/* ================================================================
   BUTTONS
   ================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1;
    letter-spacing: -0.01em;
    cursor: pointer;
    border: none;
    transition: transform var(--transition-fast),
                opacity var(--transition-fast),
                box-shadow var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
    opacity: 0.85;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* Primary */
.btn-primary {
    background: var(--button-color);
    color: var(--button-text-color);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.btn-primary:active {
    box-shadow: 0 1px 4px rgba(0, 122, 255, 0.15);
}

/* Secondary */
.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-color);
}

/* Ghost / Text button */
.btn-ghost {
    background: transparent;
    color: var(--button-color);
    padding: 12px 16px;
}

.btn-ghost:active {
    background: var(--secondary-bg);
}

/* Danger */
.btn-danger {
    background: var(--destructive);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.2);
}

.btn-danger:active {
    box-shadow: 0 1px 4px rgba(255, 59, 48, 0.15);
}

/* Sizes */
.btn-sm {
    padding: 8px 14px;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 16px 28px;
    font-size: var(--text-md);
    border-radius: var(--radius-lg);
}

/* Full width */
.btn-block {
    width: 100%;
    padding-top: 14px;
    padding-bottom: 14px;
}

/* Active state for filter/toggle buttons */
.btn-secondary.active,
.task-filter.active {
    background: var(--button-color);
    color: var(--button-text-color);
}


/* ================================================================
   CARDS
   ================================================================ */

.card {
    background: var(--section-bg);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    box-shadow: var(--card-shadow);
    transition: box-shadow var(--transition-normal);
}

.card:hover {
    box-shadow: var(--card-shadow-elevated);
}

.card-title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--text-color);
    margin-bottom: var(--spacing-xs);
    line-height: var(--line-height-tight);
}

.card-subtitle {
    font-size: var(--text-sm);
    color: var(--subtitle-text);
    line-height: var(--line-height-normal);
}

/* Card with linked detail info */
.card a {
    color: var(--link-color);
    font-weight: var(--weight-medium);
}


/* ================================================================
   FORM INPUTS
   ================================================================ */

.input-group {
    margin-bottom: var(--spacing-md);
}

.input-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--hint-color);
    margin-bottom: var(--spacing-sm);
    letter-spacing: 0.01em;
}

.input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--separator-color-opaque);
    border-radius: var(--radius-sm);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: var(--text-base);
    line-height: var(--line-height-normal);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
}

.input::placeholder {
    color: var(--hint-color);
    opacity: 0.7;
}

.input:focus {
    outline: none;
    border-color: var(--button-color);
    box-shadow: var(--input-shadow-focus);
}

.input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Select dropdown */
select.input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%238e8e93' d='M4.5 6l3.5 4 3.5-4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
    cursor: pointer;
}

/* Textarea */
textarea.input {
    min-height: 100px;
    resize: vertical;
    line-height: var(--line-height-relaxed);
}

/* Input with error state */
.input-error .input,
.input.error {
    border-color: var(--destructive);
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

.input-error-message {
    font-size: var(--text-sm);
    color: var(--destructive);
    margin-top: var(--spacing-xs);
}


/* ================================================================
   LIST ITEMS
   ================================================================ */

.list-item {
    display: flex;
    align-items: center;
    padding: 10px var(--spacing-md);
    background: var(--section-bg);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

/* Clean separator between items - uses pseudo-element for inset line */
.list-item + .list-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: var(--spacing-md);
    right: 0;
    height: 0.5px;
    background: var(--separator-color-opaque);
}

/* Rounded corners for first/last items in a group */
.list-item:first-child {
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.list-item:last-child {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.list-item:only-child {
    border-radius: var(--radius-md);
}

/* Touch feedback */
.list-item:active {
    background: var(--secondary-bg);
}

.list-item__content {
    flex: 1;
    min-width: 0;
}

.list-item__title {
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: var(--line-height-tight);
}

.list-item__subtitle {
    font-size: var(--text-sm);
    color: var(--subtitle-text);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: var(--line-height-normal);
}

.list-item__arrow {
    color: var(--hint-color);
    opacity: 0.4;
    font-size: 20px;
    font-weight: 300;
    margin-left: var(--spacing-sm);
    flex-shrink: 0;
}

/* List group shadow wrapper */
.list-group {
    background: var(--section-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
}

.list-group .list-item:first-child {
    border-radius: 0;
}

.list-group .list-item:last-child {
    border-radius: 0;
}


/* ================================================================
   SEARCH BAR
   ================================================================ */

.search-bar {
    padding: 0;
    margin-bottom: var(--spacing-sm);
    position: relative;
}

.search-bar .input {
    background: var(--secondary-bg);
    border-color: var(--separator-color-opaque);
    border-radius: var(--radius-pill);
    padding: 10px 32px 10px 16px;
    font-size: var(--text-sm);
}

.search-bar__clear {
    position: absolute;
    right: 8px;
    top: 0;
    bottom: 0;
    margin: auto 0;
    width: 18px;
    height: 18px;
    border: none;
    background: var(--hint-color);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.search-bar .input:focus {
    background: var(--bg-color);
    border-color: var(--button-color);
    box-shadow: var(--input-shadow-focus);
}

.search-bar .input::placeholder {
    color: var(--hint-color);
    opacity: 0.6;
}


/* ================================================================
   STAGE FILTER CHIPS
   ================================================================ */

.stage-chips {
    display: flex;
    gap: var(--spacing-xs);
    padding: 0 0 var(--spacing-sm);
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.stage-chips::-webkit-scrollbar {
    display: none;
}

.stage-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    cursor: pointer;
    border: 1.5px solid var(--separator-color-opaque);
    background: transparent;
    color: var(--text-color);
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.stage-chip:active {
    transform: scale(0.95);
}

.stage-chip.selected {
    background: var(--button-color);
    border-color: var(--button-color);
    color: var(--button-text-color);
}

.stage-chip--won.selected {
    background: var(--badge-success-bg);
    border-color: var(--badge-success-text);
    color: var(--badge-success-text);
}

.stage-chip--lost.selected {
    background: var(--badge-danger-bg);
    border-color: var(--badge-danger-text);
    color: var(--badge-danger-text);
}


/* ================================================================
   BADGES
   ================================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: 0.01em;
    line-height: 1.4;
    background: var(--secondary-bg);
    color: var(--text-color);
    white-space: nowrap;
}

.badge-success {
    background: var(--badge-success-bg);
    color: var(--badge-success-text);
}

.badge-danger {
    background: var(--badge-danger-bg);
    color: var(--badge-danger-text);
}

.badge-warning {
    background: var(--badge-warning-bg);
    color: var(--badge-warning-text);
}

.badge-info {
    background: var(--badge-info-bg);
    color: var(--badge-info-text);
}


/* ================================================================
   EMPTY STATE
   ================================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-md);
    color: var(--hint-color);
    min-height: 120px;
}

.empty-state__icon {
    font-size: 56px;
    margin-bottom: var(--spacing-sm);
    opacity: 0.3;
    line-height: 1;
}

.empty-state p {
    font-size: var(--text-base);
    color: var(--hint-color);
    max-width: 260px;
    line-height: var(--line-height-relaxed);
}


/* ================================================================
   LOADING / SPINNER
   ================================================================ */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    min-height: 120px;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--separator-color-opaque);
    border-top-color: var(--button-color);
    border-radius: var(--radius-round);
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}


/* ================================================================
   TOAST NOTIFICATIONS
   ================================================================ */

.toast {
    position: fixed;
    top: var(--spacing-md);
    left: var(--spacing-md);
    right: var(--spacing-md);
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    line-height: var(--line-height-normal);
    z-index: var(--z-toast);
    box-shadow: var(--toast-shadow);
    transform: translateY(calc(-100% - 40px));
    opacity: 0;
    transition: transform var(--transition-slow),
                opacity var(--transition-normal);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-success {
    background: var(--toast-success-bg);
    color: #ffffff;
}

.toast-error {
    background: var(--toast-error-bg);
    color: #ffffff;
}


/* ================================================================
   AVATAR
   ================================================================ */

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-round);
    background: var(--secondary-bg);
    color: var(--hint-color);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    flex-shrink: 0;
    margin-right: 12px;
    text-transform: uppercase;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: var(--text-sm);
    margin-right: var(--spacing-sm);
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: var(--text-lg);
}


/* ================================================================
   DIVIDER
   ================================================================ */

.divider {
    height: 0.5px;
    background: var(--separator-color-opaque);
    margin: var(--spacing-sm) 0;
}

.divider-inset {
    margin-left: var(--spacing-md);
    margin-right: var(--spacing-md);
}


/* ================================================================
   SKELETON LOADING
   ================================================================ */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--secondary-bg) 25%,
        rgba(0, 0, 0, 0.04) 50%,
        var(--secondary-bg) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 14px;
    margin-bottom: var(--spacing-sm);
    width: 80%;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-circle {
    border-radius: var(--radius-round);
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* ================================================================
   CHIPS (filter toggles)
   ================================================================ */

.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    white-space: nowrap;
    cursor: pointer;
    border: 1.5px solid var(--separator-color-opaque);
    background: transparent;
    color: var(--text-color);
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.chip:active {
    transform: scale(0.95);
}

.chip--active {
    background: var(--button-color);
    border-color: var(--button-color);
    color: var(--button-text-color);
}

.field-error {
    color: var(--destructive) !important;
}


/* ================================================================
   ICON BUTTONS (entity detail headers)
   ================================================================ */

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    transition: opacity var(--transition-fast);
}

.icon-btn:active {
    opacity: 0.7;
}

.icon-btn--primary {
    background: var(--button-color);
    color: var(--button-text-color);
}

.icon-btn--danger {
    background: var(--destructive);
    color: #fff;
}


/* ================================================================
   TASK CARD
   ================================================================ */

.task-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.task-card {
    background: var(--section-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.task-card__main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--spacing-md);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.task-card__main:active {
    background: var(--secondary-bg);
}

.task-card__left {
    display: flex;
    align-items: flex-start;
    flex: 1;
    min-width: 0;
}

.task-card__title {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--text-color);
    line-height: var(--line-height-tight);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.task-card__meta {
    font-size: var(--text-xs);
    color: var(--hint-color);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-card__arrow {
    color: var(--hint-color);
    opacity: 0.4;
    font-size: 20px;
    font-weight: 300;
    margin-left: var(--spacing-sm);
    flex-shrink: 0;
}

.task-card__expand {
    padding: 8px var(--spacing-md) 12px;
    border-top: 0.5px solid var(--separator-color-opaque);
    background: var(--secondary-bg);
}


/* ================================================================
   TASK FILTERS
   ================================================================ */

.task-filters {
    margin-bottom: var(--spacing-md);
}

.task-filters__row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.task-filters__label {
    font-size: var(--text-xs);
    color: var(--hint-color);
    font-weight: var(--weight-medium);
    flex-shrink: 0;
    min-width: 50px;
}


/* ================================================================
   DROPDOWN MENU (typeahead / search results)
   ================================================================ */

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    max-height: 240px;
    overflow-y: auto;
    margin-top: 2px;
}

.dropdown-item {
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: background-color 0.15s;
}

.dropdown-item:hover,
.dropdown-item:active {
    background: var(--bg-secondary);
}

.dropdown-item + .dropdown-item {
    border-top: 1px solid var(--border-color);
}


/* ================================================================
   MERGE SELECTION MODE
   ================================================================ */

.list-item--selectable {
    cursor: pointer;
}

.list-item--selected {
    background: color-mix(in srgb, var(--button-color) 12%, transparent);
}

.merge-checkbox {
    width: 28px;
    height: 28px;
    border: 2px solid var(--hint-color);
    border-radius: var(--radius-round);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 4px;
    margin-right: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.merge-checkbox--checked {
    background: var(--button-color);
    border-color: var(--button-color);
    color: var(--button-text-color);
}

/* Prevent iOS/Telegram long-press callout on selectable list items */
.list-item[data-contact-id] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}


/* ================================================================
   TAB SWITCHER (pill-style, used on dashboard Home/Chats)
   ================================================================ */

.tab-switcher {
    display: flex;
    background: var(--secondary-bg);
    border: 1px solid rgba(60, 60, 67, 0.12);
    border-radius: var(--radius-pill);
    padding: 3px;
}

.tab-switcher button {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--hint-color);
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.tab-switcher button.active {
    background: var(--button-color);
    color: var(--button-text-color);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
}

.tab-switcher__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    margin-left: 6px;
    background: var(--destructive);
    color: #fff;
    vertical-align: middle;
}

.tab-switcher button.active .tab-switcher__badge {
    background: rgba(255, 255, 255, 0.3);
    color: #fff;
}


/* ================================================================
   CONVERSATION LIST (chat list on dashboard)
   ================================================================ */

.conversation-list {
    display: flex;
    flex-direction: column;
}

.conversation-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    gap: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.conversation-item:active {
    opacity: 0.7;
}

.conversation-item + .conversation-item {
    border-top: 0.5px solid var(--separator-color, rgba(60, 60, 67, 0.08));
}

.conversation-item__avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-round);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: var(--weight-semibold);
    color: #fff;
    flex-shrink: 0;
    position: relative;
}

.conversation-item__platform-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.conversation-item__platform-badge svg {
    width: 18px;
    height: 18px;
}

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

.conversation-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}

.conversation-item__name {
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.conversation-item--unread .conversation-item__name {
    font-weight: var(--weight-semibold);
}

.conversation-item__time {
    font-size: var(--text-sm);
    color: var(--hint-color);
    flex-shrink: 0;
    margin-left: 8px;
}

.conversation-item--unread .conversation-item__time {
    color: var(--button-color);
}

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

.conversation-item__preview {
    font-size: var(--text-sm);
    color: var(--hint-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
    line-height: var(--line-height-normal);
}

.conversation-item--unread .conversation-item__preview {
    color: var(--text-color);
}

.conversation-item__outgoing {
    color: var(--button-color);
}

.conversation-item__badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: var(--radius-pill);
    background: var(--button-color);
    color: var(--button-text-color);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}


/* ================================================================
   TOGGLE SWITCH
   ================================================================ */

.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle__slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--separator-color-opaque);
    border-radius: var(--radius-pill);
    transition: background var(--transition-fast);
}

.toggle__slider::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle input:checked + .toggle__slider {
    background: var(--badge-success-text, #34C759);
}

.toggle input:checked + .toggle__slider::before {
    transform: translateX(20px);
}


/* ================================================================
   CUSTOM CHECKBOX (replaces native hidden by appearance:none)
   ================================================================ */

input[type="checkbox"] {
    appearance: auto;
    -webkit-appearance: checkbox;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    accent-color: var(--button-color);
    cursor: pointer;
}


/* ================================================================
   CHAT AI TOGGLE (small badge above chat messages)
   ================================================================ */

.chat-ai-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    background: var(--secondary-bg);
    color: var(--hint-color);
    border: 1px solid var(--separator-color-opaque);
    transition: all var(--transition-fast);
    margin-bottom: var(--spacing-xs);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.chat-ai-toggle--on {
    background: color-mix(in srgb, var(--badge-success-text, #34C759) 15%, transparent);
    color: var(--badge-success-text, #34C759);
    border-color: color-mix(in srgb, var(--badge-success-text, #34C759) 30%, transparent);
}

.chat-ai-toggle--warn {
    background: color-mix(in srgb, #FF9500 12%, transparent);
    color: #FF9500;
    border-color: color-mix(in srgb, #FF9500 25%, transparent);
}

.chat-ai-toggle--off {
    background: var(--secondary-bg);
    color: var(--hint-color);
    border-color: var(--separator-color-opaque);
}

.chat-ai-toggle:active {
    transform: scale(0.95);
    opacity: 0.85;
}

/* Invoice item */
.invoice-item {
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    -webkit-user-select: none;
    user-select: none;
}

.invoice-item--clickable {
    cursor: pointer;
    -webkit-touch-callout: none;
}

.invoice-item--clickable:active {
    opacity: 0.7;
}

.invoice-item__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.invoice-item__amount {
    font-weight: var(--weight-semibold);
    font-size: var(--text-base);
}

.invoice-item__bottom {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--spacing-sm);
}

.invoice-item__link {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--link-color);
    font-size: var(--text-sm);
}

.invoice-item__date {
    flex-shrink: 0;
    font-size: var(--text-sm);
    color: var(--hint-color);
}


/* ================================================================
   LEAD TITLE — inline entity (contact / company)
   ================================================================ */

.lead-title-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.lead-title-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
    min-width: 0;
}

.lead-title-entity {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--link-color);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.lead-title-entity svg {
    flex-shrink: 0;
    vertical-align: middle;
}


/* ================================================================
   DOCUMENT PREVIEW OVERLAY
   ================================================================ */

.doc-preview-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: var(--z-overlay);
    display: flex;
    flex-direction: column;
}

.doc-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: #fff;
    flex-shrink: 0;
}

.doc-preview-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.doc-preview-page-info {
    font-size: var(--text-sm);
    color: rgba(255, 255, 255, 0.7);
}

.doc-preview-body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0 8px;
}

.doc-preview-img {
    max-width: 100%;
    height: auto;
    touch-action: pinch-zoom;
    user-select: none;
    -webkit-user-select: none;
}

.doc-preview-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
}

.doc-preview-nav {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 12px;
    flex-shrink: 0;
}

.doc-preview-nav .btn {
    min-width: 48px;
    font-size: 20px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.doc-preview-nav .btn:disabled {
    opacity: 0.2;
}


/* ================================================================
   DOCUMENT SEND MODAL
   ================================================================ */

.doc-send-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-md);
}

.doc-send-modal__card {
    background: var(--bg-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    width: 100%;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.doc-send-modal__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--spacing-md);
    text-align: center;
}

.doc-send-modal__channels {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.doc-send-modal__channel {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    cursor: pointer;
    font-size: var(--text-base);
    color: var(--text-color);
    transition: background 0.15s;
}

.doc-send-modal__channel:active {
    background: var(--bg-secondary);
}

.doc-send-modal__channel:disabled {
    opacity: 0.5;
    cursor: default;
}

.doc-send-modal__footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--spacing-md);
}

.doc-send-modal__no-channels {
    text-align: center;
    color: var(--hint-color);
    font-size: var(--text-sm);
    padding: var(--spacing-md) 0;
}
