@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-bg: rgba(37, 99, 235, 0.1);
    --green: #059669;
    --green-dark: #047857;
    --green-bg: #ecfdf5;
    --green-bg-strong: #d1fae5;
    --amber: #b45309;
    --amber-bg: #fef3c7;
    --red: #b91c1c;
    --red-bg: #fee2e2;

    --navy: #0f172a;
    --navy-soft: #1e293b;
    --slate-400: #94a3b8;
    --slate-300: #cbd5e1;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e5e7eb;
    --bg-page: #f5f6f8;

    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 10px -2px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 2px 4px rgba(16, 24, 40, 0.04), 0 12px 24px -6px rgba(16, 24, 40, 0.12);
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    margin: 0;
    background: var(--bg-page);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

svg { display: block; }

/* ======================= Responsive helpers ======================= */

.mobile-topbar {
    display: none;
}

.menu-toggle {
    display: none;

    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    margin: 0;
    line-height: 0;
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

.menu-close {
    display: none;
    background: none;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    padding: 0.25rem;
    margin: 0;
    line-height: 0;
    margin-right: auto;
}

.menu-close svg {
    width: 20px;
    height: 20px;
}

.menu-close:hover {
    color: white;
}


.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 98;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.open {
    opacity: 1;
}

/* ======================= Login ======================= */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(37, 99, 235, 0.08), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(5, 150, 105, 0.08), transparent 40%),
        var(--bg-page);
}

.login-box {
    width: 100%;
    max-width: 380px;
    margin: 0 1.5rem;
    padding: 2.75rem 2.25rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.login-logo {
    width: 80px;
    height: auto;
    display: block;
    margin: 0 auto 1.25rem;
    object-fit: contain;
}

.login-box h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 0.25rem;
}

.login-box .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0 0 1.75rem;
}

.login-box form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.login-box label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0.75rem;
}

.login-box input {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-box input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-bg);
}

.login-box button {
    margin-top: 1.5rem;
    padding: 0.75rem;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.login-box button:hover { background: var(--blue-dark); }
.login-box button:active { transform: translateY(1px); }

.error {
    background: var(--red-bg);
    color: var(--red);
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    margin: 0 0 0.5rem;
}

/* ======================= App shell ======================= */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--navy);
    color: var(--slate-300);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.25rem 0.5rem 1.75rem;
}

.sidebar-logo {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-name {
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--slate-400);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.25);
    color: white;
}

.nav-item.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(148, 163, 184, 0.6);
    padding: 1rem 0.75rem 0.35rem;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0 0.25rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-user-name {
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--slate-400);
    text-transform: capitalize;
}

.logout-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 0.55rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--slate-300);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

/* ---------- Main area ---------- */

.main-area {
    flex: 1;
    min-width: 0;
}

.page-header {
    padding: 2.25rem 2.5rem 0;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.25rem;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin: 0;
}

main {
    max-width: 1180px;
    padding: 1.75rem 2.5rem 4rem;
}

section + section { margin-top: 2.5rem; }

section h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 1rem;
}

/* ---------- Metric cards ---------- */

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

.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-icon svg { width: 21px; height: 21px; }

.card-icon.blue { background: var(--blue-bg); color: var(--blue); }
.card-icon.green { background: var(--green-bg-strong); color: var(--green); }

.card-value {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.1;
}

.card-value.money { color: var(--green-dark); }

.card-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.card-detail {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
    margin-top: 0.15rem;
}

.card-hero {
    border-color: var(--green-bg-strong);
    border-width: 1px;
    border-left: 4px solid var(--green);
    background: linear-gradient(180deg, var(--green-bg) 0%, white 55%);
}

.card-hero .card-value { color: var(--green-dark); }
.card-hero .card-detail { border-top-color: rgba(5, 150, 105, 0.18); color: var(--green-dark); opacity: 0.75; }

/* ---------- Tables ---------- */

.table-wrap {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 0.85rem 1.4rem;
    font-size: 0.88rem;
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #fafbfc;
    border-bottom: 1px solid var(--border);
}

tbody tr:not(:last-child) td {
    border-bottom: 1px solid #f1f3f5;
}

tbody tr {
    transition: background 0.12s;
}

tbody tr:hover {
    background: #fafbfc;
}

td.money, th.money {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

td.money {
    font-weight: 700;
    color: var(--text-primary);
}

.estado {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
}

.estado-vendida {
    background: var(--green-bg-strong);
    color: var(--green-dark);
}

.estado-pendiente {
    background: var(--amber-bg);
    color: var(--amber);
}

/* ---------- Empty state ---------- */

.empty-state {
    background: white;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    width: 32px;
    height: 32px;
    margin-bottom: 0.85rem;
    opacity: 0.6;
}

.empty-state p {
    margin: 0.15rem 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.empty-state-detail {
    font-size: 0.82rem !important;
    color: var(--text-muted) !important;
}

/* ---------- Configuración / formularios ---------- */

.settings-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.75rem 2rem;
    max-width: 420px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.settings-form label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 0.9rem;
}

.settings-form input {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-form input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-bg);
}

.settings-form button {
    margin-top: 1.5rem;
    padding: 0.7rem;
    background: var(--blue);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.settings-form button:hover { background: var(--blue-dark); }
.settings-form button:active { transform: translateY(1px); }

.form-success {
    background: var(--green-bg-strong);
    color: var(--green-dark);
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    margin: 0 0 1rem;
}

/* ======================= Panel de Conversaciones (3 columnas) ======================= */

.conv-layout {
    flex: 1;
    display: flex;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Lista de conversaciones ---------- */

.conv-list {
    width: 340px;
    flex-shrink: 0;
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.conv-list-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 1.25rem 0.75rem;
}

.conv-list-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.conv-count {
    background: var(--blue-bg);
    color: var(--blue);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
}

.conv-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 1rem 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.conv-search svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conv-search input {
    border: none;
    background: none;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--text-primary);
    width: 100%;
    outline: none;
}

.conv-search input::placeholder {
    color: var(--text-muted);
}

.conv-items {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.5rem 0.5rem;
}

.conv-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 0.75rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: inherit;
    transition: background 0.12s;
    cursor: pointer;
}

.conv-item:hover {
    background: var(--bg-page);
}

.conv-item.active {
    background: var(--blue-bg);
}

.conv-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.conv-avatar.unread {
    background: var(--green);
}

.conv-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.conv-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conv-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.conv-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conv-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.conv-preview {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-badge {
    background: var(--green);
    color: white;
    font-size: 0.68rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0 0.3rem;
}

/* ---------- Chat activo ---------- */

.conv-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    min-width: 0;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: white;
}

.chat-back {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    line-height: 0;
}

.chat-back svg {
    width: 22px;
    height: 22px;
}

.chat-header-info {
    flex: 1;
    min-width: 0;
}

.chat-header-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header-phone {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg-page);
}

.msg {
    display: flex;
    max-width: 75%;
}

.msg-client {
    align-self: flex-start;
}

.msg-agent {
    align-self: flex-end;
}

.msg-bubble {
    padding: 0.6rem 0.9rem;
    border-radius: 16px;
    font-size: 0.88rem;
    line-height: 1.45;
    position: relative;
}

.msg-client .msg-bubble {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.msg-agent .msg-bubble {
    background: var(--blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.msg-bubble p {
    margin: 0 0 0.25rem;
}

.msg-time {
    font-size: 0.65rem;
    opacity: 0.65;
    display: block;
    text-align: right;
}

.msg-agent .msg-time {
    color: rgba(255, 255, 255, 0.8);
}

.msg-client .msg-time {
    color: var(--text-muted);
}

.chat-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background: white;
}

.chat-attach, .chat-send {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem;
    line-height: 0;
    border-radius: 50%;
    transition: background 0.12s, color 0.12s;
}

.chat-attach:hover, .chat-send:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.chat-attach svg, .chat-send svg {
    width: 20px;
    height: 20px;
}

.chat-attach:disabled, .chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chat-input input {
    flex: 1;
    padding: 0.6rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 0.88rem;
    font-family: inherit;
    background: var(--bg-page);
    outline: none;
    transition: border-color 0.15s;
}

.chat-input input:focus {
    border-color: var(--blue);
}

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

/* ---------- Empty state del chat ---------- */

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    background: var(--bg-page);
}

.chat-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.chat-empty h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 0.35rem;
}

.chat-empty p {
    font-size: 0.88rem;
    margin: 0;
    color: var(--text-muted);
}

/* ======================= Responsive: tablets y mobile ======================= */

/* Tablets (≤ 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .page-header {
        padding: 1.75rem 1.5rem 0;
    }

    main {
        padding: 1.5rem 1.5rem 3rem;
    }

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

/* Móviles (≤ 768px) */
@media (max-width: 768px) {
    /* Sidebar se convierte en menú lateral deslizable */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        height: 100vh;
        z-index: 99;
        transition: left 0.3s ease;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    }



    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.open {
        pointer-events: auto;
    }

    /* Botón menú hamburguesa visible */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Botón cerrar (X) visible dentro de la sidebar */
    .menu-close {
        display: flex;
        align-items: center;
        justify-content: center;
    }


    /* Top bar móvil con hamburguesa y título */
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        background: white;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 100;
    }


    .mobile-topbar .brand-name-mobile {
        font-weight: 700;
        font-size: 1rem;
        color: var(--text-primary);
    }

    .mobile-topbar .avatar-mobile {
        width: 30px;
        height: 30px;
        border-radius: 50%;
        background: var(--blue);
        color: white;
        font-weight: 600;
        font-size: 0.8rem;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-left: auto;
        flex-shrink: 0;
    }

    /* Ocultar page-header normal, se reemplaza con topbar */
    .page-header {
        display: none;
    }

    main {
        padding: 1.25rem 1rem 3rem;
    }

    .page-header {
        padding: 1.25rem 1rem 0;
    }

    .page-header h1 {
        font-size: 1.3rem;
    }

    /* Métricas: 1 columna en móvil */
    .metricas {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .card {
        padding: 1.1rem 1.2rem;
    }

    .card-value {
        font-size: 1.6rem;
    }

    /* Tablas: scroll horizontal */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-wrap table {
        min-width: 600px;
    }

    th, td {
        padding: 0.7rem 1rem;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    /* Settings card full width */
    .settings-card {
        max-width: 100%;
        padding: 1.25rem 1.25rem;
    }

    section + section {
        margin-top: 1.75rem;
    }

    section h2 {
        font-size: 0.95rem;
    }

    /* ===== Conversaciones responsive ===== */

    .conv-layout {
        height: calc(100vh - 52px); /* restar altura del mobile-topbar */
    }

    .conv-list {
        width: 100%;
        border-right: none;
    }

    .conv-list.show-chat {
        display: none;
    }

    .conv-chat {
        display: none;
    }

    /* Cuando hay un chat activo en móvil, mostrar solo el chat */
    .conv-chat:only-child,
    .conv-chat:has(.chat-header) {
        display: flex;
        width: 100%;
    }

    .chat-back {
        display: flex;
    }

    .chat-messages {
        padding: 0.85rem;
    }

    .msg {
        max-width: 90%;
    }

    .chat-input {
        padding: 0.6rem 0.85rem;
    }

    .conv-list-header {
        padding: 0.85rem 1rem 0.5rem;
    }

    .conv-search {
        margin: 0 0.75rem 0.5rem;
    }

    .conv-items {
        padding: 0 0.25rem 0.25rem;
    }

    .conv-item {
        padding: 0.6rem 0.65rem;
    }
}

/* Móviles pequeños (≤ 480px) */
@media (max-width: 480px) {
    .login-box {
        margin: 0 1rem;
        padding: 2rem 1.5rem;
    }

    .login-box h1 {
        font-size: 1.2rem;
    }

    main {
        padding: 1rem 0.85rem 2.5rem;
    }

    .card {
        padding: 1rem 1rem;
    }

    .card-value {
        font-size: 1.4rem;
    }

    .table-wrap table {
        min-width: 520px;
    }

    th, td {
        padding: 0.6rem 0.75rem;
        font-size: 0.78rem;
    }
}
