:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --border: #e2e6ed;
    --text: #1f2430;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --sidebar-bg: #111827;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #1f2937;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: inherit; text-decoration: none; }

/* ---------- Auth pages ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #111827 0%, #1e293b 45%, #0f172a 100%);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo .badge {
    display: inline-flex;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 12px;
}

.auth-logo h1 {
    font-size: 18px;
    margin: 0 0 4px;
}

.auth-logo p {
    margin: 0;
    color: var(--text-muted);
    font-size: 13px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.field input, .field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    /* >=16px — dưới mức này Safari/Chrome mobile tự động zoom vào khi focus ô nhập. */
    font-size: 16px;
    background: #fff;
    color: var(--text);
}

.field input:focus, .field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f3f4f6; }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #bbf7d0; }
.hidden { display: none !important; }

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

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.sidebar-brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 16px;
}

.sidebar-brand .badge {
    display: inline-flex;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 8px;
}

.sidebar-brand h1 {
    font-size: 15px;
    color: #fff;
    margin: 0;
}

.sidebar-brand p {
    font-size: 12px;
    color: #94a3b8;
    margin: 2px 0 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
}

.nav-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; border-left-color: var(--primary); }

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px 0;
    border-top: 1px solid rgba(255,255,255,.08);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.topbar h2 {
    font-size: 16px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    flex-shrink: 0;
    color: var(--text);
}

.sidebar-backdrop {
    display: none;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-chip .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

.user-chip .role {
    font-size: 11px;
    color: var(--text-muted);
}

.content {
    padding: 24px;
    flex: 1;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    margin: 0;
    font-size: 15px;
}

.card-body { padding: 20px; }

table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }

.pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.pill-super { background: #ede9fe; color: #6d28d9; }
.pill-admin { background: #dbeafe; color: #1d4ed8; }
.pill-none { background: #f3f4f6; color: var(--text-muted); }

.pill-pending { background: #fef3c7; color: #92400e; }
.pill-processing { background: #dbeafe; color: #1d4ed8; }
.pill-completed { background: #dcfce7; color: #15803d; }
.pill-cancelled { background: #fee2e2; color: #b91c1c; }

.pill-lg { padding: 5px 14px; font-size: 13px; }

.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.filter-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-tab:hover:not(.active) { background: #f3f4f6; }

.search-input {
    padding: 7px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    /* >=16px — dưới mức này Safari/Chrome mobile tự động zoom vào khi focus ô nhập. */
    font-size: 16px;
    min-width: 220px;
}
.search-input:focus { outline: none; border-color: var(--primary); }

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

.pagination .btns { display: flex; gap: 6px; }

.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.history-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.history-item .time { color: var(--text-muted); font-size: 12px; min-width: 130px; }

.row-actions { display: flex; gap: 6px; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13.5px;
}

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
    overscroll-behavior: contain;
}

/* Khoá scroll trang nền trong lúc có modal mở — chặn việc lướt trong modal kéo luôn page đằng sau. */
body.body-scroll-locked {
    overflow: hidden;
}

.modal {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 15px; }

.chat-header-meta {
    margin-top: 3px;
    font-size: 12px;
    color: var(--text-muted);
    overflow-wrap: break-word;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Modal toàn màn hình (dịch 1 tin nhắn sang tiếng Việt) ---------- */
.modal-backdrop.modal-backdrop-fullscreen { padding: 0; }
.modal.modal-fullscreen {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}
.modal-fullscreen .modal-body {
    flex: 1;
    overflow-y: auto;
}

.msg-translate-block { margin-bottom: 22px; }
.msg-translate-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.msg-translate-original {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted);
    white-space: pre-wrap;
    overflow-wrap: break-word;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: 10px;
}
.msg-translate-text {
    font-size: 19px;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    padding: 14px 16px;
    background: #eef2ff;
    border-radius: 10px;
    color: var(--text);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-card .label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 700;
}

/* ---------- Chatbox ---------- */
.chat-modal {
    width: 100%;
    max-width: 900px;
    /* Cố định 85% chiều cao viewport ở mọi kích thước màn hình — dùng dvh (trừ đúng phần thanh địa
       chỉ/toolbar trình duyệt đang chiếm) với vh làm fallback cho trình duyệt cũ không hỗ trợ dvh. */
    height: 85vh;
    height: 85dvh;
    max-height: 760px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-body {
    flex: 1;
    display: flex;
    min-height: 0;
}

.chat-sidebar {
    width: 260px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px;
    background: #fafbfc;
}

.chat-sidebar-group {
    margin-bottom: 14px;
}

.chat-sidebar-group summary {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 0;
}

.chat-tpl-item {
    display: block;
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    margin-top: 6px;
    font-size: 12.5px;
    cursor: pointer;
}
.chat-tpl-item:hover { border-color: var(--primary); background: #f5f8ff; }
.chat-tpl-item .tpl-title { font-weight: 600; margin-bottom: 2px; }
.chat-tpl-item .tpl-preview { color: var(--text-muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.chat-thread {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble-row { display: flex; }
.chat-bubble-row.outbound { justify-content: flex-end; }

/* max-width sống ở đây (flex item với container width xác định), không phải trên .chat-bubble bên
   trong — nếu để % trên 1 phần tử không có width rõ ràng bên trong flex row, trình duyệt có thể
   fallback về min-content (1 ký tự/dòng) thay vì tính đúng theo chiều rộng khung chat. */
.chat-bubble-wrap {
    max-width: 75%;
    min-width: 0;
}

.chat-bubble {
    max-width: 100%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
}
.chat-bubble-row.inbound .chat-bubble { background: #f1f3f5; color: var(--text); border-bottom-left-radius: 4px; }
.chat-bubble-row.outbound .chat-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble-row.outbound.failed .chat-bubble { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }

.chat-image-wrap { display: block; }
.chat-bubble-image {
    display: block;
    max-width: 260px;
    max-height: 260px;
    width: auto;
    border-radius: 12px;
    cursor: pointer;
    object-fit: cover;
}
.chat-image-fallback { display: none; }
.chat-image-wrap.broken .chat-bubble-image,
.chat-image-wrap.broken a { display: none; }
.chat-image-wrap.broken .chat-image-fallback {
    display: block;
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 12.5px;
}
.chat-image-fallback a { color: inherit; text-decoration: underline; }

.chat-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 3px;
}
.chat-bubble-row.outbound .chat-meta { justify-content: flex-end; }
.chat-bubble-row.inbound .chat-meta { justify-content: flex-start; }

.chat-copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    padding: 2px;
    opacity: .55;
    border-radius: 4px;
}
.chat-copy-btn:hover { opacity: 1; background: var(--bg); }
.chat-copy-btn.copied { opacity: 1; color: var(--success); }

/* Nút copy email ở cột "Khách hàng" trong bảng đơn hàng — dùng lại style .chat-copy-btn ở trên. */
.cell-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
}
.cell-copy-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cell-copy .chat-copy-btn { flex-shrink: 0; }

/* ---------- Ô soạn tin: icon (kịch bản/đính kèm/dịch) xếp hàng riêng phía trên, để hàng nhập tin
   nhắn chính được rộng hết cỡ — dễ gõ trên mobile màn hẹp (thay cho layout icon-cạnh-textarea cũ). */
.chat-compose {
    border-top: 1px solid var(--border);
    padding: 10px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-toolbar-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-icon-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
}
.chat-icon-btn:hover { background: #eef0f3; }
.chat-icon-btn.active { border-color: var(--primary); background: #eef2ff; }

/* Chỉ hiện trên mobile (xem media query max-width:700px) — desktop đã có sidebar kịch bản sẵn rồi. */
.chat-tpl-toggle-btn { display: none; }

/* Ô nhập tiếng Việt cần dịch + nút "Dịch →" — ẩn mặc định, hiện khi bấm icon 🌐 (chat-icon-btn). Dịch
   xong ghi kết quả vào ô nhập chính (chat-input) bên dưới để admin xem/sửa rồi tự bấm gửi thủ công. */
.chat-translate-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f5f8ff;
    border: 1px dashed var(--primary);
    border-radius: 10px;
    padding: 8px;
}

.chat-translate-row textarea {
    width: 100%;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.4;
    overflow-y: hidden;
    max-height: 100px;
    background: #fff;
}
.chat-translate-row textarea:focus { outline: none; border-color: var(--primary); }

.chat-translate-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.chat-translate-lang-select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 12.5px;
    background: #fff;
    cursor: pointer;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chat-input-row textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    /* >=16px — dưới mức này Safari/Chrome mobile tự động zoom vào khi focus ô nhập. */
    font-size: 16px;
    font-family: inherit;
    line-height: 1.4;
    overflow-y: hidden;
    /* max-height thật do JS tính theo 5 dòng (autoResizeChatInput) — giá trị dưới đây chỉ là fallback
       phòng khi JS chưa kịp chạy. */
    max-height: 120px;
}
.chat-input-row textarea:focus { outline: none; border-color: var(--primary); }

/* Nút gửi dạng icon máy bay giấy tròn (SEND_ICON_SVG) thay vì nút chữ "Gửi" — gọn hơn trên mobile. */
.chat-send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
}
.chat-send-btn:hover { opacity: .9; }
.chat-send-btn:disabled { opacity: .5; cursor: default; }

.chat-image-preview-strip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px 8px;
}
.chat-image-preview-strip.hidden { display: none; }
.chat-image-preview-strip img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.chat-image-preview-remove {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    color: var(--text-muted);
    padding: 4px;
}
.chat-image-preview-remove:hover { color: var(--danger); }

.chat-conn-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    margin-right: 6px;
}
.chat-conn-dot.connected { background: var(--success); }
.chat-conn-dot.connecting { background: #f59e0b; }

@media (max-width: 700px) {
    .chat-modal {
        max-width: 96vw;
        /* Vẫn giữ 85% chiều cao trên mobile — không full màn hình. dvh trừ đúng phần thanh địa
           chỉ Chrome đang chiếm, vh làm fallback cho trình duyệt cũ. */
        height: 85vh;
        height: 85dvh;
        max-height: none;
    }
    .chat-body { flex-direction: column; }
    /* Sidebar kịch bản chiếm quá nhiều chỗ trên màn hẹp — ẩn hẳn, thay bằng nút 📋 cạnh ô nhập mở
       modal chọn kịch bản riêng (xem #chat-tpl-toggle-btn). */
    .chat-sidebar { display: none; }
    .chat-tpl-toggle-btn { display: inline-flex; }
    .chat-bubble-wrap { max-width: 88%; }
}

/* ---------- Table cuộn ngang thay vì bị bóp méo ---------- */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-scroll table { min-width: 640px; }

/* ---------- Mobile: sidebar thành drawer, layout xếp dọc ---------- */
@media (max-width: 860px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 110;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 6px 0 30px rgba(0,0,0,.3);
        width: 260px;
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, .45);
        z-index: 100;
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }
    .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

    .menu-toggle-btn { display: inline-flex; align-items: center; }

    .topbar { padding: 0 14px; gap: 8px; }
    .topbar h2 { font-size: 14.5px; }
    .user-chip { gap: 6px; }
    .user-chip .role { display: none; }
    .user-chip > div:first-child { display: none; }

    .content { padding: 14px; }

    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .value { font-size: 20px; }

    .card-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .card-header > div {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .card-header .search-input,
    .card-header select.search-input {
        flex: 1;
        min-width: 140px;
    }

    .modal, .chat-modal { max-width: 94vw; }

    .row-actions { flex-wrap: wrap; }
}

/* ---------- Chấm báo tin nhắn mới (realtime) ---------- */
.unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    margin-right: 6px;
    box-shadow: 0 0 0 3px #fee2e2;
    animation: unread-pulse 1.6s ease-in-out infinite;
}

@keyframes unread-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

tr.order-row-unread { background: #fef9f4; }
tr.order-row-unread:hover { background: #fef3e7; }
