/* ============================================================
   LAYOUT
   ============================================================ */

html:has(.app-body),
.app-body {
    height: 100%;
    overflow: hidden;
}

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: var(--header-height) 1fr;
    height: 100vh;
    overflow: hidden;
}

.app-header {
    grid-column: 1 / -1;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-6);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    border-color: var(--border-focus);
    color: var(--brand-primary);
}

.sidebar-backdrop {
    display: none;
}

html[dir="rtl"] .nav-item {
    border-left: 0;
    border-right: 3px solid transparent;
}

html[dir="rtl"] .nav-item.active {
    border-right-color: var(--brand-primary);
}

.app-sidebar {
    position: sticky;
    top: var(--header-height);
    align-self: start;
    height: calc(100vh - var(--header-height));
    background: var(--bg-primary);
    border-right: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-sidebar nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: var(--space-4) 0;
}

.sidebar-footer {
    flex: 0 0 auto;
    margin-top: auto;
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-primary);
}

.app-content {
    background: var(--bg-body);
    padding: var(--space-6);
    overflow-y: auto;
    min-height: 0;
}

/* ============================================================
   HEADER
   ============================================================ */

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.header-brand i {
    font-size: var(--fs-xl);
    color: var(--brand-primary);
}

.header-brand span {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.header-brand .brand-accent {
    color: var(--brand-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-5);
}

.header-timer {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.header-timer i { color: var(--color-warning); }
.header-timer.danger { color: var(--color-danger); border-color: var(--color-danger); }
.header-timer.danger i { color: var(--color-danger); }

.header-user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
}

/* ============================================================
   SIDEBAR NAV
   ============================================================ */

.nav-section {
    margin-bottom: var(--space-6);
}

.nav-section-title {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    padding: 0 var(--space-5);
    margin-bottom: var(--space-2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    color: var(--text-secondary);
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    transition: var(--transition);
    border-left: 3px solid transparent;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--brand-glow);
    color: var(--brand-primary);
    border-left-color: var(--brand-primary);
}

.nav-item i {
    width: 18px;
    text-align: center;
    font-size: var(--fs-md);
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-sm);
}

html[data-theme="light"] .card {
    box-shadow: var(--shadow-sm);
}

.task-slot-placeholder {
    border-style: dashed;
    background: rgba(21, 27, 36, 0.45);
    pointer-events: none;
    display: flex;
    flex-direction: column;
}

html[data-theme="light"] .task-slot-placeholder {
    background: rgb(21 27 36 / 20%);
}

.task-slot-placeholder:hover {
    border-color: var(--border-default);
    box-shadow: none;
}

.task-ghost-bar {
    display: block;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    height: 10px;
}

.task-slot-placeholder .task-ghost-hint {
    margin-top: auto;
    padding-top: var(--space-3);
    text-align: center;
    font-size: var(--fs-xs);
    color: var(--text-dim);
    line-height: 1.4;
}

html[data-theme="light"] .task-slot-placeholder .task-ghost-hint,
html[data-theme="light"] .task-slot-placeholder .task-ghost-hint i {
    color: #ffffff;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.card-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.card-value {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-bold);
    font-family: var(--font-mono);
    color: var(--text-primary);
    margin-top: var(--space-2);
}

.card-value.success { color: var(--color-success); }
.card-value.danger { color: var(--color-danger); }
.card-value.info { color: var(--color-info); }

.card-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.card-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: var(--fs-lg);
}

.card-icon.green { background: var(--brand-glow); color: var(--brand-primary); }
.card-icon.blue { background: var(--trust-glow); color: var(--trust-primary); }
.card-icon.red { background: rgba(240,68,56,0.1); color: var(--color-danger); }
.card-icon.yellow { background: rgba(245,166,35,0.1); color: var(--color-warning); }

/* Trust card — hakediş */
.card.card-trust {
    border-color: var(--trust-primary);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(26,111,239,0.05) 100%);
}

/* ============================================================
   PROGRESS BAR (Loader)
   ============================================================ */

.progress-wrapper {
    width: 100%;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.progress-label {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    font-weight: var(--fw-medium);
}

.progress-value {
    font-size: var(--fs-sm);
    font-family: var(--font-mono);
    font-weight: var(--fw-bold);
    color: var(--brand-primary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-surface);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--brand-dark) 0%, var(--brand-primary) 100%);
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 20px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3));
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

/* ============================================================
   FORMS
   ============================================================ */

.form-group {
    margin-bottom: var(--space-5);
}

.form-label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--fs-md);
    transition: var(--transition);
}

.form-input:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

.form-input::placeholder {
    color: var(--text-dim);
}

.form-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--fs-md);
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7A8D' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    font-size: var(--fs-md);
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--brand-primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--brand-dark);
    box-shadow: var(--shadow-glow);
    color: #fff;
}

.btn-trust {
    background: var(--trust-primary);
    color: #fff;
}
.btn-trust:hover {
    background: var(--trust-dark);
}

.btn-danger {
    background: rgba(240,68,56,0.15);
    color: var(--color-danger);
    border: 1px solid rgba(240,68,56,0.3);
}
.btn-danger:hover {
    background: rgba(240,68,56,0.25);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}
.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-sm);
}

/* Admin users: Askıya Al / Aktif Et share Askıya Al's natural width. */
.btn-status-toggle {
    position: relative;
    justify-content: center;
}
.btn-status-toggle-ghost {
    visibility: hidden;
    pointer-events: none;
    display: inline-flex;
    align-items: center;
    gap: inherit;
    white-space: nowrap;
}
.btn-status-toggle-real {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: inherit;
    white-space: nowrap;
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--fs-lg);
}

/* ============================================================
   TABLE
   ============================================================ */

.data-table {
    width: 100%;
    font-size: var(--fs-sm);
}

.data-table thead th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-primary);
    white-space: nowrap;
}

.data-table thead th a.th-sort {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.data-table thead th a.th-sort:hover,
.data-table thead th a.th-sort.is-active {
    color: var(--text-primary);
}

.data-table thead th a.th-sort i {
    font-size: 10px;
    opacity: 0.4;
}

.data-table thead th a.th-sort.is-active i {
    opacity: 1;
    color: var(--brand-primary);
}

.data-table tbody td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr:hover td {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.data-table .mono {
    font-family: var(--font-mono);
    font-size: var(--fs-xs);
    letter-spacing: 0.02em;
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    border-radius: 9999px;
    letter-spacing: 0.02em;
}

.badge-success { background: rgba(0,210,106,0.12); color: var(--color-success); }
.badge-danger { background: rgba(240,68,56,0.12); color: var(--color-danger); }
.badge-warning { background: rgba(245,166,35,0.12); color: var(--color-warning); }
.badge-info { background: rgba(26,111,239,0.12); color: var(--color-info); }
.badge-muted { background: var(--bg-surface); color: var(--text-muted); }

/* ============================================================
   COPY BUTTON
   ============================================================ */

.copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.copy-btn:hover {
    background: var(--bg-surface);
    color: var(--brand-primary);
}

.copy-btn.copied {
    color: var(--color-success);
}

/* ============================================================
   TOAST NOTIFICATION
   ============================================================ */

.toast {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    padding: var(--space-3) var(--space-5);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
    color: var(--text-primary);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* ============================================================
   GRID UTILS
   ============================================================ */

.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .app-layout { grid-template-columns: 1fr; }

    /* Mobilde boş görev slotlarını tek karta indir (gerçek görevler etkilenmez) */
    .task-slot-placeholder ~ .task-slot-placeholder { display: none; }

    .sidebar-toggle { display: inline-flex; order: 99; }

    .app-header {
        padding: 0 12px;
        gap: 8px;
    }

    .header-brand-text { display: none; }

    .header-right { gap: 8px; }
    .header-user { display: none; }
    .header-logout {
        width: 40px;
        height: 40px;
        padding: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .header-timer {
        padding: 4px 8px;
        font-size: var(--fs-sm);
    }

    .theme-switch {
        width: 54px;
        height: 30px;
    }

    .theme-switch-thumb {
        width: 22px;
        height: 22px;
        transform: translateX(25px);
    }

    html[data-theme="light"] .theme-switch-thumb {
        transform: translateX(0);
    }

    .app-sidebar {
        display: flex;
        position: fixed;
        top: var(--header-height);
        left: 0;
        width: min(280px, 86vw);
        height: calc(100dvh - var(--header-height));
        z-index: 140;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-lg);
        border-right: 1px solid var(--border-default);
    }

    html[dir="rtl"] .app-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
        border-right: 0;
        border-left: 1px solid var(--border-default);
    }

    body.sidebar-open .app-sidebar,
    html[dir="rtl"] body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        top: var(--header-height);
        z-index: 130;
        background: rgba(0, 0, 0, 0.5);
    }

    .sidebar-backdrop[hidden] { display: none; }

    .app-content {
        padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px));
    }

    .page-title {
        font-size: var(--fs-lg);
        margin-bottom: var(--space-4);
    }

    .page-subtitle {
        margin-bottom: var(--space-4);
    }

    .card { padding: 14px; }

    .card:has(.data-table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .data-table:has(thead) { min-width: 640px; }

    .app-content .grid[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }

    .card-header {
        gap: var(--space-3);
    }

    .card-header form {
        width: 100%;
    }

    .card-header form .form-input,
    .card-header form > div[style*="width"] {
        width: 100% !important;
        min-width: 0;
    }

    .card-header .select2-container {
        width: 100% !important;
    }

    .channel-add-form {
        flex-direction: column;
        align-items: stretch;
    }

    .transfer-power-stats {
        gap: var(--space-4);
    }

    .transfer-offer-stage {
        min-height: 240px;
        padding: var(--space-4);
    }

    .transfer-detail-card {
        min-height: 0;
    }
}

/* ============================================================
   PAGE UTILITIES
   ============================================================ */

.page-title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-6);
}

.page-subtitle {
    font-size: var(--fs-md);
    color: var(--text-muted);
    margin-top: calc(var(--space-1) * -1);
    margin-bottom: var(--space-6);
}

/* ============================================================
   LANGUAGE SWITCHER
   ============================================================ */

.lang-switcher {
    position: relative;
}

#lang-toggle {
    min-width: 40px;
    padding: var(--space-2) var(--space-3);
}

.lang-flag-icon {
    width: 24px;
    height: 18px;
    object-fit: cover;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
    display: block;
    flex-shrink: 0;
}

.lang-option .lang-flag-icon {
    width: 22px;
    height: 16px;
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: var(--space-2);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: var(--space-2) 0;
    display: none;
    z-index: 999;
}

.lang-dropdown.show {
    display: block;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    transition: var(--transition);
    text-decoration: none;
}

.lang-option:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.lang-option.active {
    color: var(--brand-primary);
    font-weight: var(--fw-semibold);
}

/* ============================================================
   THEME SWITCH
   ============================================================ */

.theme-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    width: 62px;
    height: 32px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    appearance: none;
    font-family: inherit;
    transition: var(--transition);
}

.theme-switch:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

.theme-switch:hover {
    border-color: var(--border-focus);
}

.theme-switch-icon {
    position: relative;
    z-index: 1;
    font-size: 11px;
    line-height: 1;
    width: 14px;
    text-align: center;
    pointer-events: none;
}

.theme-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
    transform: translateX(31px);
    transition: transform 0.2s ease, background 0.2s ease;
    pointer-events: none;
}

html[data-theme="light"] .theme-switch-thumb {
    transform: translateX(0);
}

html[data-theme="light"] .theme-switch-sun {
    color: var(--color-warning);
}

html:not([data-theme="light"]) .theme-switch-moon {
    color: var(--brand-primary);
}

.swal2-popup {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

.swal2-title,
.swal2-html-container {
    color: var(--text-primary) !important;
}

.swal2-actions .swal2-confirm {
    background-color: var(--brand-primary) !important;
}

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-danger { color: var(--color-danger); }

.transfer-power-card {
    margin-bottom: var(--space-6);
}

.transfer-power-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.transfer-power-title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.transfer-power-stats {
    display: flex;
    gap: var(--space-6);
}

.transfer-power-label {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.transfer-power-value {
    font-family: var(--font-mono);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.transfer-power-track {
    direction: ltr;
    position: relative;
    height: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    overflow: hidden;
    --power: 0%;
}

.transfer-power-spectrum {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, #1A6FEF 0%, #3B82F6 28%, #A855F7 52%, #F59E0B 76%, #EF4444 100%);
    clip-path: inset(0 calc(100% - var(--power)) 0 0);
    transition: clip-path 0.55s ease;
}

.transfer-power-spectrum::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--power) - 10px);
    width: 18px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35));
    pointer-events: none;
}

.channel-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.channel-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
}

.channel-label {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.channel-phone {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.channel-speeds {
    display: flex;
    gap: var(--space-6);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-subtle);
}

.channel-speed-label {
    display: block;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.channel-speed-value {
    font-family: var(--font-mono);
    font-size: var(--fs-md);
    font-weight: 700;
    color: var(--brand-primary);
}

.channel-card-empty {
    border-style: dashed;
}

.channel-add-form {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    margin-top: var(--space-3);
}

.channel-add-form .phone-input-group {
    display: flex;
    flex: 1;
}

.channel-add-form .phone-prefix {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--fs-sm);
}

.channel-add-form .form-input {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

@media (max-width: 900px) {
    .channel-list {
        grid-template-columns: 1fr;
    }
}

.transfer-detail-card {
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.transfer-offer-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 320px;
    padding: var(--space-6);
}

.transfer-offer-waiting,
.transfer-offer-missed,
.transfer-offer-preview {
    display: none;
}

.transfer-offer-stage.is-waiting .transfer-offer-waiting,
.transfer-offer-stage.is-missed .transfer-offer-missed {
    display: flex;
}

.transfer-offer-stage.is-preview .transfer-offer-preview {
    display: flex;
}

.transfer-offer-stage.is-claimed,
.transfer-detail-card.is-claimed .transfer-offer-stage {
    display: none !important;
}

/* Claimed transfer details are read-only: block manual text selection so the
   values can't be copy/pasted (the intentional copy button still works). */
.transfer-detail-card.is-claimed,
.transfer-detail-card.is-claimed * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}
.transfer-detail-card.is-claimed .copy-btn {
    cursor: pointer;
}

.transfer-offer-stage:not(.is-preview) #offer-claim-btn {
    display: none !important;
}

.transfer-offer-waiting,
.transfer-offer-missed {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    font-size: var(--fs-lg);
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.5;
    max-width: 280px;
}

.transfer-offer-waiting i,
.transfer-offer-missed i {
    font-size: 2.75rem;
    display: block;
}

.transfer-offer-waiting i {
    color: var(--text-secondary);
}

.transfer-offer-missed i {
    color: var(--color-danger);
}

#offer-claim-btn.btn-danger {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
}

#offer-claim-btn.btn-danger:hover {
    background: #d13a32;
    border-color: #d13a32;
}

.transfer-offer-preview {
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
}

.transfer-offer-name {
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
}

.transfer-offer-amount {
    font-family: var(--font-mono);
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--color-success);
}

.transfer-detail-body {
    margin-top: var(--space-4);
}

.transfer-action-card {
    min-height: 420px;
}

.transfer-action-card.is-loading .card-header,
.transfer-action-card.is-loading #transfer-form {
    display: none;
}

.transfer-loader {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 380px;
    gap: var(--space-5);
    text-align: center;
}

.transfer-action-card.is-loading .transfer-loader {
    display: flex;
}

.transfer-spinner-wrap {
    position: relative;
    width: 104px;
    height: 104px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.transfer-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 4px solid rgba(240, 244, 248, 0.08);
    border-top-color: var(--brand-primary);
    animation: transfer-spin 0.85s linear infinite;
}

.transfer-spinner-step {
    font-family: var(--font-mono);
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.04em;
}

.transfer-loader-text {
    font-size: var(--fs-md);
    font-weight: 600;
    color: var(--text-secondary);
}

@keyframes transfer-spin {
    to { transform: rotate(360deg); }
}

.line-adjust {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.line-adjust form {
    margin: 0;
}

.line-adjust-count {
    min-width: 1.5em;
    text-align: center;
    font-weight: 700;
}

.line-adjust-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

.line-adjust-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ============================================================
   PRESENCE / STATUS BADGES
   ============================================================ */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-xs);
    white-space: nowrap;
}
.status-dot i { font-size: 8px; }
.status-online { color: var(--color-success); }
.status-offline { color: var(--text-dim); }
.status-dot .status-seen { color: var(--text-muted); }

/* ============================================================
   LOGIN NOTIFICATION STACK (admin)
   ============================================================ */
#tf-notif-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
    width: calc(100vw - 32px);
    pointer-events: none;
}

.tf-notif {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 34px 12px 12px;
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-left: 3px solid var(--brand-primary);
    border-radius: var(--radius-md, 10px);
    box-shadow: var(--shadow-lg);
    animation: tf-notif-in 0.22s ease;
}

.tf-notif-admin { border-left-color: var(--color-warning); }

/* Event variants */
.tf-notif-login    { border-left-color: var(--brand-primary); }
.tf-notif-takeover { border-left-color: #2563EB; }
.tf-notif-logout   { border-left-color: var(--text-dim); }
.tf-notif-idle     { border-left-color: var(--color-warning); }
.tf-notif-register,
.tf-notif-register_ref { border-left-color: var(--brand-primary); }
.tf-notif-contact { border-left-color: var(--brand-primary); }
.tf-notif-contact .tf-notif-icon {
    background: color-mix(in srgb, var(--brand-primary) 18%, transparent);
    color: var(--brand-primary);
}

.tf-notif-takeover .tf-notif-icon {
    background: color-mix(in srgb, #2563EB 20%, transparent);
    color: #2563EB;
}
.tf-notif-logout .tf-notif-icon {
    background: color-mix(in srgb, var(--text-secondary) 18%, transparent);
    color: var(--text-secondary);
}
.tf-notif-idle .tf-notif-icon {
    background: color-mix(in srgb, var(--color-warning) 20%, transparent);
    color: var(--color-warning);
}

/* User event variants (toast) */
.tf-notif-task_new             { border-left-color: var(--brand-primary); }
.tf-notif-task_reminder        { border-left-color: var(--color-warning); }
.tf-notif-task_expired         { border-left-color: var(--color-danger, #FF4D4F); }
.tf-notif-withdrawal_approved  { border-left-color: var(--color-success, #00D26A); }
.tf-notif-withdrawal_rejected  { border-left-color: var(--color-danger, #FF4D4F); }
.tf-notif-referral_joined      { border-left-color: var(--brand-primary); }

.tf-notif-task_reminder .tf-notif-icon { background: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-warning); }
.tf-notif-task_expired .tf-notif-icon,
.tf-notif-withdrawal_rejected .tf-notif-icon { background: color-mix(in srgb, var(--color-danger, #FF4D4F) 18%, transparent); color: var(--color-danger, #FF4D4F); }
.tf-notif-withdrawal_approved .tf-notif-icon { background: color-mix(in srgb, var(--color-success, #00D26A) 18%, transparent); color: var(--color-success, #00D26A); }

@keyframes tf-notif-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.tf-notif-icon {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--brand-primary) 18%, transparent);
    color: var(--brand-primary);
    font-size: 13px;
}
.tf-notif-admin .tf-notif-icon {
    background: color-mix(in srgb, var(--color-warning) 20%, transparent);
    color: var(--color-warning);
}

.tf-notif-body { min-width: 0; }
.tf-notif-msg {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}
.tf-notif-badge {
    margin-top: 3px;
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-warning);
    background: color-mix(in srgb, var(--color-warning) 15%, transparent);
    border-radius: 4px;
    padding: 1px 6px;
}
.tf-notif-badge-code {
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    color: var(--brand-primary);
    background: color-mix(in srgb, var(--brand-primary) 15%, transparent);
}
.tf-notif-time {
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.tf-notif-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}
.tf-notif-close:hover { color: var(--text-primary); background: var(--bg-tertiary, rgba(255,255,255,0.06)); }

/* Toast auto-dismiss (5s) fade-out */
.tf-notif.tf-notif-out { animation: tf-notif-out 0.25s ease forwards; }
@keyframes tf-notif-out {
    to { opacity: 0; transform: translateX(24px); }
}

/* ─────────────────────────────────────────────
   Header notification bell + badge
   ───────────────────────────────────────────── */
.notif-bell {
    position: relative;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-default);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-md, 10px);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.notif-bell:hover { color: var(--text-primary); border-color: var(--brand-primary); }
.notif-bell.has-unread i { animation: tf-bell-ring 1.2s ease-in-out; }
@keyframes tf-bell-ring {
    0%, 100% { transform: rotate(0); }
    10%, 30% { transform: rotate(-12deg); }
    20%, 40% { transform: rotate(12deg); }
}
.notif-bell-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-danger, #FF4D4F);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--bg-primary, #0B0F14);
}

/* ─────────────────────────────────────────────
   Notification panel (slide-in from the right)
   ───────────────────────────────────────────── */
#tf-notif-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
}
#tf-notif-overlay.open { opacity: 1; visibility: visible; }

#tf-notif-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 400px;
    max-width: 92vw;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-default);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.24s ease;
    display: flex;
    flex-direction: column;
}
#tf-notif-panel.open { transform: translateX(0); }

.tf-np-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--border-default);
}
.tf-np-title {
    font-size: var(--fs-md, 15px);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.tf-np-count {
    font-size: 11px;
    color: var(--color-warning);
    background: color-mix(in srgb, var(--color-warning) 15%, transparent);
    border-radius: 10px;
    padding: 1px 8px;
}
.tf-np-actions { display: flex; align-items: center; gap: 6px; }
.tf-np-readall {
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
}
.tf-np-readall:hover { color: var(--text-primary); border-color: var(--brand-primary); }
.tf-np-readall:disabled { opacity: 0.45; cursor: default; }
.tf-np-close {
    width: 32px;
    height: 32px;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 6px;
    font-size: 16px;
    flex: 0 0 auto;
}
.tf-np-close:hover { color: var(--text-primary); background: var(--bg-tertiary, rgba(255,255,255,0.06)); }

.tf-np-list {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px;
}

.tf-np-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    border-radius: var(--radius-md, 10px);
    cursor: pointer;
    border: 1px solid transparent;
}
.tf-np-item:hover { background: var(--bg-tertiary, rgba(255,255,255,0.04)); }
.tf-np-item + .tf-np-item { margin-top: 2px; }
.tf-np-item.unread { background: color-mix(in srgb, var(--brand-primary) 8%, transparent); }
.tf-np-item.unread::before {
    content: '';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--brand-primary);
}
.tf-np-ic {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--brand-primary) 18%, transparent);
    color: var(--brand-primary);
    font-size: 13px;
}
.tf-np-ic.v-takeover { background: color-mix(in srgb, #2563EB 20%, transparent); color: #2563EB; }
.tf-np-ic.v-logout { background: color-mix(in srgb, var(--text-secondary) 18%, transparent); color: var(--text-secondary); }
.tf-np-ic.v-idle { background: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-warning); }
.tf-np-ic.v-register,
.tf-np-ic.v-register_ref { background: color-mix(in srgb, var(--brand-primary) 18%, transparent); color: var(--brand-primary); }
.tf-np-ic.v-contact { background: color-mix(in srgb, var(--brand-primary) 18%, transparent); color: var(--brand-primary); }
.tf-np-ic.v-task_reminder { background: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-warning); }
.tf-np-ic.v-task_expired,
.tf-np-ic.v-withdrawal_rejected { background: color-mix(in srgb, var(--color-danger, #FF4D4F) 18%, transparent); color: var(--color-danger, #FF4D4F); }
.tf-np-ic.v-withdrawal_approved { background: color-mix(in srgb, var(--color-success, #00D26A) 18%, transparent); color: var(--color-success, #00D26A); }
.tf-np-ic.v-referral_joined { background: color-mix(in srgb, var(--brand-primary) 18%, transparent); color: var(--brand-primary); }
.tf-np-body { min-width: 0; flex: 1 1 auto; }
.tf-np-msg { font-size: var(--fs-sm); color: var(--text-primary); font-weight: 600; word-break: break-word; }
.tf-np-item-badge {
    display: inline-block;
    margin-top: 2px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--color-warning);
    background: color-mix(in srgb, var(--color-warning) 15%, transparent);
    border-radius: 4px;
    padding: 1px 6px;
}
.tf-np-item-badge.tf-notif-badge-code {
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    color: var(--brand-primary);
    background: color-mix(in srgb, var(--brand-primary) 15%, transparent);
}
.tf-np-time { margin-top: 3px; font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

.tf-np-more {
    display: block;
    width: 100%;
    margin: 8px 0 4px;
    padding: 10px;
    border: 1px dashed var(--border-default);
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-md, 10px);
}
.tf-np-more:hover { color: var(--text-primary); border-color: var(--brand-primary); }
.tf-np-empty { text-align: center; color: var(--text-muted); padding: 40px 16px; font-size: var(--fs-sm); }

@media (max-width: 480px) {
    #tf-notif-panel { width: 100vw; max-width: 100vw; }
    /* Mobile sidebar drawer opens full-width, like the notification panel. */
    .app-sidebar { width: 100vw; }
}

/* ---- Contact messages inbox ---- */
.app-content:has(.cm-page) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.cm-page {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.cm-page-head {
    flex-shrink: 0;
}

.cm-page-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.cm-page-sub {
    margin-top: 4px;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.cm-inbox {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.cm-inbox-toolbar {
    flex-shrink: 0;
    padding: 0;
    border-bottom: 1px solid var(--border-default);
}

.cm-inbox-filters {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    width: 100%;
    min-width: 0;
    align-items: stretch;
}

.cm-toolbar-status {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-right: 1px solid var(--border-default);
    background: var(--bg-primary);
    min-width: 0;
}

.cm-toolbar-status .form-select {
    width: 100%;
    height: 36px;
}

.cm-toolbar-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    min-width: 0;
}

.cm-search-wrap {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.cm-search-wrap i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: var(--fs-xs);
    pointer-events: none;
}

.cm-search-wrap .form-input {
    width: 100%;
    padding-left: 30px;
    height: 36px;
    font-size: var(--fs-sm);
}

.cm-toolbar-btn {
    flex: 0 0 auto;
    height: 36px;
    min-width: 36px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

html[data-theme="light"] .cm-toolbar-status {
    background: #FFFFFF;
}

html[data-theme="dark"] .cm-toolbar-status,
html:not([data-theme="light"]) .cm-toolbar-status {
    background: var(--bg-secondary);
}

.cm-inbox-body {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    background: var(--bg-body);
}

.cm-list-pane {
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-default);
    background: var(--bg-primary);
}

.cm-list-actions {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-default);
    min-height: 40px;
    background: color-mix(in srgb, var(--bg-elevated) 55%, var(--bg-primary));
}

.cm-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    margin: 0;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
}

.cm-check input {
    width: 15px;
    height: 15px;
    accent-color: var(--brand-primary);
    cursor: pointer;
    margin: 0;
}

.cm-bulk-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
}

.cm-bulk-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    white-space: nowrap;
    padding: 0 6px 0 2px;
}

.cm-bulk-sep {
    width: 1px;
    height: 16px;
    background: var(--border-default);
    margin: 0 4px;
    flex: 0 0 auto;
}

.cm-act-btn {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
    padding: 0;
    font-size: 13px;
    transition: background 0.15s ease, color 0.15s ease;
}

.cm-act-btn:hover {
    background: color-mix(in srgb, var(--bg-surface) 80%, transparent);
    color: var(--text-primary);
}

.cm-act-btn.is-danger:hover {
    background: color-mix(in srgb, var(--color-danger, #FF4D4F) 14%, transparent);
    color: var(--color-danger, #FF4D4F);
}

.cm-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.cm-list-pager {
    flex-shrink: 0;
    border-top: 1px solid var(--border-default);
    background: var(--bg-primary);
}

.cm-list-pager > div {
    padding: 8px 10px !important;
    border-top: none !important;
    gap: 4px !important;
    flex-wrap: wrap;
}

.cm-list-pager .btn {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
}

.cm-list-empty,
.cm-reader-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-6);
    font-size: var(--fs-sm);
}

.cm-list-empty i,
.cm-reader-empty i {
    font-size: 2.4rem;
    opacity: 0.7;
}

.cm-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
    border-left: 3px solid transparent;
    background: transparent;
}

.cm-item-check {
    flex: 0 0 auto;
    padding-top: 3px;
}

.cm-star {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    margin-top: 0;
    border: 0;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.cm-star:hover {
    color: #F5A623;
    background: color-mix(in srgb, #F5A623 12%, transparent);
}

.cm-star.is-on {
    color: #F5A623;
}

.cm-star-inline {
    color: #F5A623;
    margin-right: 6px;
    font-size: 0.9em;
}

.cm-item.is-important .cm-item-name {
    color: var(--text-primary);
}

.cm-item-link {
    flex: 1 1 auto;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.cm-item:hover {
    background: color-mix(in srgb, var(--bg-surface) 70%, transparent);
}

.cm-item.is-checked {
    background: color-mix(in srgb, var(--brand-primary) 8%, transparent);
}

.cm-item.is-active {
    background: color-mix(in srgb, var(--brand-primary) 10%, var(--bg-primary));
    border-left-color: var(--brand-primary);
    border-bottom-color: var(--border-default);
}

.cm-item.is-unread {
    background: color-mix(in srgb, var(--brand-primary) 6%, transparent);
}

.cm-item.is-unread.is-active {
    background: color-mix(in srgb, var(--brand-primary) 12%, var(--bg-primary));
}

.cm-item.is-unread .cm-item-name {
    font-weight: 700;
    color: var(--text-primary);
}

.cm-item.is-unread .cm-item-name::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-primary);
    margin-right: 8px;
    vertical-align: middle;
}

.cm-item.is-read .cm-item-name,
.cm-item.is-read .cm-item-email,
.cm-item.is-read .cm-item-subject {
    color: var(--text-muted);
    font-weight: 400;
}

.cm-item-top {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 2px;
}

.cm-item-name {
    font-size: var(--fs-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cm-item-time {
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.cm-item-email {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.cm-item-subject {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cm-reader {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-elevated);
}

.cm-reader-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-default);
    background: color-mix(in srgb, var(--bg-elevated) 88%, var(--bg-primary));
}

.cm-reader-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.cm-reader-actions form {
    margin: 0;
}

.cm-reader-subject {
    font-size: var(--fs-lg);
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.cm-reader-from {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.cm-reader-from a {
    color: var(--brand-primary);
    text-decoration: none;
}

.cm-reader-from a:hover {
    text-decoration: underline;
}

.cm-reader-date {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.cm-reader-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--space-5);
    font-size: var(--fs-sm);
    line-height: 1.7;
    color: var(--text-primary);
}

/* Light: senders white, reader soft gray — clear pane separation. */
html[data-theme="light"] .cm-list-pane {
    background: #FFFFFF;
}

html[data-theme="light"] .cm-list-actions {
    background: #F7F9FC;
}

html[data-theme="light"] .cm-reader {
    background: #F1F4F8;
}

html[data-theme="light"] .cm-reader-header {
    background: #EAEFF5;
    border-bottom-color: var(--border-default);
}

html[data-theme="light"] .cm-item {
    border-bottom-color: #E2E8F0;
}

html[data-theme="light"] .cm-item:hover {
    background: #F7F9FC;
}

html[data-theme="light"] .cm-item.is-active {
    background: color-mix(in srgb, var(--brand-primary) 8%, #FFFFFF);
}

html[data-theme="light"] .cm-item.is-unread {
    background: color-mix(in srgb, var(--brand-primary) 5%, #FFFFFF);
}

html[data-theme="light"] .cm-list-pager {
    background: #FFFFFF;
    border-top-color: var(--border-default);
}

/* Dark: keep familiar contrast, ensure divider lines show. */
html[data-theme="dark"] .cm-list-pane,
html:not([data-theme="light"]) .cm-list-pane {
    background: var(--bg-secondary);
}

html[data-theme="dark"] .cm-reader,
html:not([data-theme="light"]) .cm-reader {
    background: var(--bg-primary);
}

html[data-theme="dark"] .cm-item,
html:not([data-theme="light"]) .cm-item {
    border-bottom-color: var(--border-subtle);
}

@media (max-width: 900px) {
    .app-content:has(.cm-page) {
        overflow-y: auto;
    }

    .cm-page {
        min-height: auto;
    }

    .cm-inbox {
        min-height: 70vh;
    }

    .cm-inbox-filters {
        grid-template-columns: 1fr;
    }

    .cm-toolbar-status {
        border-right: none;
        border-bottom: 1px solid var(--border-default);
    }

    .cm-inbox-body {
        grid-template-columns: 1fr;
        min-height: 640px;
    }

    .cm-list-pane {
        border-right: none;
        border-bottom: 1px solid var(--border-default);
        max-height: 280px;
    }

    .cm-reader {
        min-height: 360px;
    }
}
