/* ===== ASOSIY O'ZGARUVCHILAR ===== */
:root {
  --primary:        #4F46E5;
  --primary-light:  #6366F1;
  --primary-dark:   #4338CA;
  --accent:         #0D9488;
  --accent-light:   #14B8A6;
  --warning:        #F59E0B;
  --warning-light:  #FCD34D;
  --danger:         #DC2626;
  --danger-light:   #FECACA;
  --bg:             #F0F4F8;
  --surface:        #FFFFFF;
  --border:         #E2E8F0;
  --text:           #0F172A;
  --text-muted:     #64748B;
  --sidebar-width:  260px;

  --stock-ok-bg:    #D1FAE5;
  --stock-ok-text:  #047857;
  --stock-ok-dot:   #10B981;
  --stock-low-bg:   #FEF3C7;
  --stock-low-text: #B45309;
  --stock-low-dot:  #F59E0B;
  --stock-empty-bg: #FEE2E2;
  --stock-empty-text:#B91C1C;
  --stock-empty-dot: #EF4444;

  --chart-1: #4A90D9;
  --chart-2: #4CAF50;
  --chart-3: #F5A623;
  --chart-4: #E53935;
  --chart-5: #AB47BC;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); font-size: clamp(12px, 2.5vw, 14px); line-height: 1.5; overflow-x: hidden; min-height: 100vh; min-width: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
input, select, button, textarea { font-size: inherit; font-family: inherit; max-width: 100%; }

/* ===== LAYOUT ===== */
.app-wrapper   { display: flex; min-height: 100vh; overflow-x: hidden; }
.sidebar       { width: var(--sidebar-width); background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%); position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; z-index: 100; display: flex; flex-direction: column; transition: transform 0.3s; box-shadow: 4px 0 20px rgba(0,0,0,0.08); }
.main-content  { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; position: relative; z-index: 101; overflow-x: hidden; }
.topbar        { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 clamp(8px, 3vw, 24px); min-height: 52px; height: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; position: sticky; top: 0; z-index: 50; flex-shrink: 0; }
.page-body     { padding: clamp(8px, 3vw, 24px); flex: 1; min-height: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.page-body h1  { font-size: clamp(16px, 4vw, 22px); font-weight: 700; margin-bottom: clamp(12px, 3vw, 24px); color: var(--text); word-break: break-word; }

/* ===== SIDEBAR ===== */
.sidebar-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo   { flex: 1; min-width: 0; }
.sidebar-close  { display: none; flex-shrink: 0; width: 36px; height: 36px; align-items: center; justify-content: center; background: rgba(255,255,255,0.15); border: none; border-radius: 8px; color: #fff; cursor: pointer; transition: background 0.2s; }
.sidebar-close:hover { background: rgba(255,255,255,0.25); }
.sidebar-logo h1 { color: #fff; font-size: 15px; font-weight: 600; }
.sidebar-logo span { color: rgba(255,255,255,0.55); font-size: 11px; }
.sidebar-nav   { padding: 12px 0; flex: 1; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 199; pointer-events: none; opacity: 0; transition: opacity 0.3s; }
@media (min-width: 769px) { .sidebar-overlay { display: none !important; } }
@media (max-width: 768px) { .sidebar-overlay.open { pointer-events: auto; opacity: 1; } }
.nav-section   { padding: 8px 16px 4px; color: rgba(255,255,255,0.4); font-size: 10px; text-transform: uppercase; letter-spacing: 1px; }
.nav-item      { display: flex; align-items: center; gap: 10px; padding: 9px 20px; color: rgba(255,255,255,0.75); font-size: 13px; transition: all 0.15s; border-left: 3px solid transparent; }
.nav-item:hover{ background: rgba(255,255,255,0.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; border-left-color: var(--accent-light); }
.nav-item svg  { width: 16px; height: 16px; flex-shrink: 0; }

/* ===== KARTALAR ===== */
.card          { background: var(--surface); border-radius: clamp(8px, 3vw, 16px); border: 1px solid var(--border); padding: clamp(12px, 3vw, 20px); box-shadow: 0 2px 12px rgba(0,0,0,0.04); min-width: 0; }
.card-header   { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.card-title    { font-size: clamp(13px, 2.5vw, 15px); font-weight: 600; color: var(--text); min-width: 0; }

/* Stat kartalar */
.stat-grid     { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 2vw, 16px); margin-bottom: clamp(12px, 3vw, 24px); }
.stat-card     { background: var(--surface); border-radius: clamp(8px, 2vw, 16px); border: 1px solid var(--border); padding: clamp(10px, 2vw, 18px) clamp(12px, 2vw, 20px); box-shadow: 0 2px 12px rgba(0,0,0,0.04); min-width: 0; }
.stat-label    { font-size: clamp(10px, 2vw, 12px); color: var(--text-muted); margin-bottom: 4px; }
.stat-value    { font-size: clamp(18px, 4vw, 26px); font-weight: 600; color: var(--text); }
.stat-card.blue   { border-left: 4px solid var(--primary-light); }
.stat-card.green  { border-left: 4px solid var(--accent); }
.stat-card.yellow { border-left: 4px solid var(--warning); }
.stat-card.red    { border-left: 4px solid var(--danger); }

/* ===== JADVALLAR ===== */
.table-wrap    { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 12px; border: 1px solid var(--border); min-width: 0; }
table          { width: 100%; min-width: 280px; border-collapse: collapse; background: var(--surface); font-size: clamp(11px, 2vw, 13px); }
thead th       { background: #F8FAFC; padding: clamp(6px, 1.5vw, 11px) clamp(8px, 2vw, 14px); text-align: left; font-size: clamp(10px, 1.8vw, 12px); font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td       { padding: clamp(6px, 1.5vw, 11px) clamp(8px, 2vw, 14px); border-bottom: 1px solid #F2F3F4; font-size: clamp(11px, 2vw, 13px); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #EBF5FB; }

/* ===== TUGMALAR ===== */
.btn           { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: clamp(6px, 1.5vw, 8px) clamp(10px, 2vw, 16px); border-radius: 8px; font-size: clamp(11px, 2vw, 13px); font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; white-space: nowrap; min-width: 0; flex-shrink: 0; }
.btn-primary   { background: var(--primary-light); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-success   { background: var(--accent); color: #fff; }
.btn-success:hover { background: #0E6B5A; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #992D22; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary-light); color: var(--primary-light); }
.btn-sm        { padding: 4px 8px; font-size: clamp(10px, 1.8vw, 12px); }
.btn-icon      { padding: 4px; width: 28px; height: 28px; min-width: 28px; justify-content: center; }

/* ===== FORMALAR ===== */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
.form-control  { width: 100%; min-width: 0; padding: clamp(6px, 1.5vw, 9px) clamp(8px, 2vw, 12px); border: 1.5px solid var(--border); border-radius: 8px; font-size: clamp(12px, 2.5vw, 13px); color: var(--text); background: var(--surface); outline: none; transition: border-color 0.15s; font-family: inherit; }
.form-control:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(46,134,193,0.12); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237F8C8D' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 28px; }
.form-grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(8px, 2vw, 16px); }
.form-grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: clamp(8px, 2vw, 16px); }
.form-error    { font-size: 11px; color: var(--danger); margin-top: 4px; }

/* ===== BADGE'LAR ===== */
.badge         { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-ok      { background: var(--stock-ok-bg); color: var(--stock-ok-text); }
.badge-ok::before { background: var(--stock-ok-dot); }
.badge-low     { background: var(--stock-low-bg); color: var(--stock-low-text); }
.badge-low::before { background: var(--stock-low-dot); }
.badge-empty   { background: var(--stock-empty-bg); color: var(--stock-empty-text); }
.badge-empty::before { background: var(--stock-empty-dot); }
.badge-blue    { background: #EBF5FB; color: #1A5276; }
.badge-blue::before { background: #2980B9; }
.badge-gray    { background: #F2F3F4; color: #626567; }
.badge-gray::before { background: #95A5A6; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 8px; }
.modal-box     { background: var(--surface); border-radius: 14px; padding: clamp(12px, 3vw, 24px); width: 100%; max-width: min(480px, calc(100vw - 16px)); max-height: min(90vh, calc(100vh - 16px)); overflow-y: auto; }
.modal-title   { font-size: clamp(14px, 3vw, 16px); font-weight: 600; margin-bottom: 12px; }

/* ===== QIDIRUV DROPDOWN ===== */
.search-wrap   { position: relative; }
.search-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--surface); border: 1.5px solid var(--primary-light); border-radius: 0 0 8px 8px; z-index: 99; max-height: 240px; overflow-y: auto; }
.search-item   { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); font-size: 13px; }
.search-item:hover { background: #EBF5FB; }

/* ===== ALERT ===== */
.alert         { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-success { background: var(--stock-ok-bg); color: var(--stock-ok-text); border: 1px solid #ABEBC6; }
.alert-danger  { background: var(--stock-empty-bg); color: var(--stock-empty-text); border: 1px solid #F1948A; }
.alert-warning { background: var(--stock-low-bg); color: var(--stock-low-text); border: 1px solid #F7DC6F; }

/* ===== BACKUP SAHIFASI ===== */
.backup-item   { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.backup-item:last-child { border-bottom: none; }
.backup-name   { font-size: 13px; font-weight: 500; color: var(--text); }
.backup-meta   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.backup-size   { font-size: 12px; font-weight: 600; color: var(--primary-light); margin-right: 10px; }

/* ===== PAGINATION ===== */
nav ul.pagination { display: flex; gap: 4px; flex-wrap: wrap; list-style: none; }
nav ul.pagination li { display: inline; }
nav ul.pagination a, nav ul.pagination span { display: inline-block; padding: 6px 12px; border-radius: 6px; font-size: 13px; }
nav ul.pagination a { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
nav ul.pagination a:hover { border-color: var(--primary-light); color: var(--primary-light); }
nav ul.pagination li.active span, nav ul.pagination li.disabled span { display: inline-block; padding: 6px 12px; border-radius: 6px; font-size: 13px; }
nav ul.pagination li.active span { background: var(--primary-light); color: #fff; border: 1px solid var(--primary-light); }
nav ul.pagination li.disabled span { color: var(--text-muted); cursor: not-allowed; border: 1px solid var(--border); background: var(--surface); }

/* ===== RESPONSIVE ===== */
.hamburger     { display: flex; align-items: center; justify-content: center; background: none; border: none; cursor: pointer; padding: 6px; color: var(--text); }
/* Katta ekranda sidebar yopilganda */
@media (min-width: 769px) {
  .sidebar-closed .sidebar { transform: translateX(-100%); }
  .sidebar-closed .main-content { margin-left: 0; }
  .sidebar-close { display: flex !important; }
}

/* 200px – 359px: juda kichik ekran */
/* Filter / form row utilities for small screens */
.filter-input-wrap { flex: 1; min-width: 0; }

@media (max-width: 359px) {
  :root { --sidebar-width: 100%; }
  .sidebar       { width: 100%; transform: translateX(-100%); }
  .sidebar.open  { transform: translateX(0); z-index: 202; }
  .sidebar-close { display: flex !important; }
  .sidebar-header { padding: 12px 12px 8px; }
  .sidebar-logo h1 { font-size: 13px; }
  .sidebar-logo span { font-size: 10px; }
  .nav-item      { padding: 8px 12px; font-size: 12px; gap: 8px; }
  .nav-section   { padding: 6px 12px 2px; font-size: 9px; }
  .main-content  { margin-left: 0; }
  .topbar        { padding: 0 8px; min-height: 48px; gap: 4px; }
  .topbar-user   { max-width: 80px; font-size: 11px; }
  .page-body     { padding: 8px; }
  .card          { padding: 10px; }
  .card-header   { margin-bottom: 8px; }
  .card-title    { font-size: 12px; }
  .stat-grid     { grid-template-columns: 1fr; gap: 8px; margin-bottom: 12px; }
  .stat-card     { padding: 10px 12px; }
  .stat-label    { font-size: 10px; }
  .stat-value    { font-size: 20px; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; gap: 8px; }
  .btn           { padding: 6px 10px; font-size: 11px; }
  .btn-sm        { padding: 3px 6px; font-size: 10px; }
  .notification-dropdown { width: calc(100vw - 16px); right: 8px; left: 8px; margin-left: auto; max-width: none; }
  nav ul.pagination a, nav ul.pagination span { padding: 4px 8px; font-size: 11px; }
  .backup-item   { flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px 12px; }
  .alert         { padding: 8px 12px; font-size: 12px; }
  .hamburger     { display: flex; }
  body.sidebar-open { overflow: hidden; }
  select.form-control { width: 100% !important; max-width: none !important; }
  .filter-row .form-control { min-width: 0; }
  [style*="min-width: 200px"] { min-width: 0 !important; }
}

/* 360px – 479px */
@media (min-width: 360px) and (max-width: 479px) {
  .stat-grid     { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .stat-grid   { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: min(260px, 100%); }
  .sidebar       { width: var(--sidebar-width); transform: translateX(-100%); }
  .sidebar.open  { transform: translateX(0); z-index: 202; }
  .sidebar-close { display: flex !important; }
  .main-content  { margin-left: 0; }
  .hamburger     { display: flex; }
  .stat-grid     { grid-template-columns: 1fr 1fr; }
  .form-grid-2   { grid-template-columns: 1fr; }
  .form-grid-3   { grid-template-columns: 1fr; }
  .page-body     { padding: 12px; }
  body.sidebar-open { overflow: hidden; }
  .notification-dropdown { width: min(360px, calc(100vw - 24px)); }
}

@media (max-width: 480px) {
  .stat-grid   { grid-template-columns: 1fr; }
  .topbar-user { max-width: 90px; }
}

/* ===== TOPBAR ===== */
.topbar-right { display: flex; align-items: center; gap: clamp(4px, 1vw, 12px); margin-left: auto; flex-wrap: wrap; min-width: 0; }
.topbar-user { font-size: clamp(11px, 2.2vw, 13px); color: var(--text-muted); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-notif-wrap { display: flex; align-items: center; margin-left: 4px; flex-shrink: 0; }
.nav-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; font-size: 9px; font-weight: 700; color: #fff; background: var(--danger); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.nav-badge-chat { background: var(--primary-light); }
.hamburger { flex-shrink: 0; min-width: 36px; }

/* ===== NOTIFICATION DROPDOWN ===== */
.notification-dropdown-wrap { position: relative; }
.notification-bell { position: relative; }
.notification-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; font-size: 10px; font-weight: 600; color: #fff; background: var(--danger); border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.notification-dropdown { position: absolute; top: 100%; right: 0; margin-top: 8px; width: min(360px, calc(100vw - 16px)); max-width: calc(100vw - 16px); max-height: min(400px, 70vh); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.12); z-index: 150; overflow: hidden; }
.notification-dropdown-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: clamp(8px, 2vw, 12px) clamp(10px, 2vw, 16px); border-bottom: 1px solid var(--border); font-size: clamp(12px, 2.5vw, 13px); font-weight: 600; flex-wrap: wrap; }
.notification-dropdown-header a { color: var(--primary-light); font-weight: 500; }
.notification-dropdown-list { max-height: 320px; overflow-y: auto; }
.notification-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s; }
.notification-item:hover { background: #F8FAFC; }
.notification-item.unread { background: #EBF5FB; }
.notification-item-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notification-item-message { font-size: 12px; color: var(--text-muted); }
.notification-item-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.notification-empty, .notification-loading { padding: 24px; text-align: center; font-size: 13px; color: var(--text-muted); }
[x-cloak] { display: none !important; }

/* ===== CHAT LAYOUT ===== */
.chat-layout { display: flex; height: calc(100vh - 140px); min-height: 400px; background: var(--surface); border-radius: 16px; border: 1px solid var(--border); overflow: hidden; }
.chat-sidebar { width: 280px; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: #FAFBFC; }
.chat-sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
.chat-sidebar-header h3 { font-size: 15px; font-weight: 600; }
.chat-contacts { flex: 1; overflow-y: auto; }
.chat-contact { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 0.15s; }
.chat-contact:hover, .chat-contact.active { background: #EBF5FB; }
.chat-contact-avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; background: var(--primary-light); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; overflow: hidden; }
.chat-contact-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-online-dot { position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--text-muted); border: 2px solid #FAFBFC; }
.chat-online-dot.online { background: var(--accent); }
.chat-contact-info { flex: 1; min-width: 0; }
.chat-contact-name { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.chat-contact-role { display: block; font-size: 11px; color: var(--text-muted); }
.chat-contact-last { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact { position: relative; }
.chat-contact-unread { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); min-width: 18px; height: 18px; padding: 0 5px; font-size: 10px; font-weight: 700; background: var(--primary-light); color: #fff; border-radius: 9px; display: flex; align-items: center; justify-content: center; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.chat-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 14px; }
.chat-conversation { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); background: #FAFBFC; }
.chat-header-user { display: flex; align-items: center; gap: 10px; }
.chat-avatar-sm { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; overflow: hidden; }
.chat-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.chat-header-name { font-size: 14px; font-weight: 600; }
.chat-typing-indicator { display: block; font-size: 11px; color: var(--text-muted); font-style: italic; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-message { display: flex; }
.chat-message.sent { justify-content: flex-end; }
.chat-message.received { justify-content: flex-start; }
.chat-message-bubble { max-width: 70%; padding: 10px 14px; border-radius: 14px; position: relative; }
.chat-message.sent .chat-message-bubble { background: var(--primary-light); color: #fff; border-bottom-right-radius: 4px; }
.chat-message.received .chat-message-bubble { background: #F1F5F9; color: var(--text); border-bottom-left-radius: 4px; }
.chat-reply-preview { padding: 6px 10px; margin-bottom: 6px; background: rgba(0,0,0,0.08); border-radius: 8px; border-left: 3px solid var(--primary-light); }
.chat-message.received .chat-reply-preview { background: rgba(0,0,0,0.05); }
.chat-reply-sender { display: block; font-size: 10px; font-weight: 600; margin-bottom: 2px; opacity: 0.9; }
.chat-reply-body { font-size: 11px; opacity: 0.85; }
.chat-message-body { font-size: 13px; }
.chat-message-image img { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; }
.chat-message-product { display: flex; flex-direction: column; gap: 8px; }
.chat-product-image { display: block; }
.chat-product-image img { max-width: 120px; max-height: 120px; border-radius: 8px; display: block; }
.chat-product-info { display: flex; flex-direction: column; gap: 2px; }
.chat-product-name { font-weight: 600; font-size: 13px; }
.chat-product-detail { font-size: 12px; opacity: 0.9; }
.chat-product-date { font-size: 11px; opacity: 0.8; font-style: italic; }
.chat-voice-player { max-width: 100%; height: 32px; margin-top: 4px; }
.chat-message-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 10px; opacity: 0.8; }
.chat-message-actions { display: flex; gap: 4px; }
.chat-message-actions button { background: none; border: none; cursor: pointer; padding: 2px; font-size: 12px; opacity: 0.8; }
.chat-message-actions button:hover { opacity: 1; }
.chat-input-area { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: #FAFBFC; }
.chat-input-actions { display: flex; gap: 8px; align-items: center; }
.chat-file-btn { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; min-width: 40px; min-height: 40px; padding: 0; font-size: 20px; font-weight: 300; line-height: 1; border: 1.5px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text); transition: border-color 0.2s, background 0.2s, color 0.2s; }
.chat-file-btn:hover { border-color: var(--primary-light); background: rgba(79, 70, 229, 0.08); color: var(--primary-light); }
.chat-file-btn:active { background: rgba(79, 70, 229, 0.12); }
.chat-input-wrap { flex: 1; }
.chat-input { margin: 0; }
.chat-reply-bar { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px; margin-bottom: 4px; background: #E2E8F0; border-radius: 6px; font-size: 12px; color: var(--text-muted); }
.chat-reply-bar button { background: none; border: none; cursor: pointer; font-size: 16px; padding: 0 4px; }

/* product modal */
.modal-product { max-width: 420px; }
.product-list-wrap { max-height: 200px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; }
.product-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.product-list-item:last-child { border-bottom: none; }
.product-list-item:hover { background: #F1F5F9; }
.product-list-item.selected { background: var(--primary-light); color: #fff; }
.product-list-img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.product-list-placeholder { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; background: #E2E8F0; border-radius: 6px; font-size: 18px; }
.product-list-info { display: flex; flex-direction: column; gap: 2px; }
.product-list-detail { font-size: 11px; opacity: 0.85; }
.product-selected-info { padding: 10px; background: #F1F5F9; border-radius: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }

/* notification index */
.notification-unread { background: #EBF5FB; }
.text-muted { color: var(--text-muted); }

@media (max-width: 768px) {
  .chat-layout { flex-direction: column; height: auto; min-height: 400px; }
  .chat-sidebar { width: 100%; max-height: 200px; }
}

@media (max-width: 480px) {
  .stat-grid   { grid-template-columns: 1fr; }
}

@media (max-width: 359px) {
  .chat-layout { min-height: 320px; }
  .chat-sidebar { max-height: 160px; }
  .chat-contact { padding: 8px 12px; gap: 8px; }
  .chat-message-bubble { max-width: 90%; }
  .modal-product { max-width: 100%; }
}

/* ===== DASHBOARD RESPONSIVE (global) ===== */
.dashboard-charts { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(12px, 2vw, 20px); margin-bottom: clamp(16px, 3vw, 24px); }
.dash-card { background: var(--surface); border-radius: clamp(12px, 4vw, 24px); padding: clamp(12px, 3vw, 24px); box-shadow: 0 4px 24px rgba(0,0,0,0.06); min-width: 0; }
.dash-card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.dash-card-title { font-size: clamp(13px, 2.5vw, 15px); font-weight: 700; color: var(--text); }
.dash-card-link { font-size: clamp(11px, 2vw, 12px); color: var(--primary-light); text-decoration: none; font-weight: 500; }
.donut-wrap { position: relative; width: min(200px, 50vw); height: min(200px, 50vw); max-width: 200px; max-height: 200px; margin: 0 auto; }
.donut-wrap canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-top, .donut-bot { font-size: clamp(10px, 2vw, 12px); font-weight: 500; color: var(--text-muted); }
.donut-num { font-size: clamp(20px, 6vw, 32px); font-weight: 800; color: var(--text); line-height: 1.1; }
.dashboard-bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(12px, 2vw, 20px); margin-bottom: clamp(16px, 3vw, 24px); }
.dash-bar-card { background: var(--surface); border-radius: clamp(12px, 4vw, 24px); padding: clamp(12px, 3vw, 24px); box-shadow: 0 4px 24px rgba(0,0,0,0.06); min-width: 0; }
.dash-bar-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.dash-bar-title { font-size: clamp(12px, 2.5vw, 15px); font-weight: 700; color: var(--text); }
.dash-bar-divider { height: 1px; background: var(--border); margin-bottom: 12px; }
.dash-bar-item { margin-bottom: 12px; }
.dash-bar-item:last-child { margin-bottom: 0; }
.dash-bar-track { height: 6px; background: #f3f4f6; border-radius: 99px; margin-bottom: 8px; overflow: hidden; }
.dash-bar-fill { height: 100%; border-radius: 99px; transition: width 1s cubic-bezier(.4,0,.2,1); }
.dash-bar-info { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px; }
.dash-bar-name { font-size: clamp(11px, 2vw, 13px); font-weight: 500; color: var(--text); min-width: 0; }
.dash-bar-amount { font-size: clamp(11px, 2vw, 13px); font-weight: 600; color: var(--text); }
.dash-bar-total { font-weight: 400; color: var(--text-muted); font-size: clamp(10px, 1.8vw, 12px); }
.dash-bar-empty { padding: clamp(16px, 3vw, 24px); text-align: center; color: var(--text-muted); font-size: clamp(12px, 2.5vw, 14px); }
.dashboard-tables { margin-top: clamp(16px, 3vw, 24px); }
.dash-table-card { margin-bottom: clamp(16px, 3vw, 24px); }
.dashboard-tables .dash-two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(12px, 2vw, 24px); }

@media (max-width: 1200px) {
  .dashboard-charts { grid-template-columns: repeat(2, 1fr); }
  .dashboard-bars { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .dashboard-charts { grid-template-columns: 1fr; }
  .dashboard-bars { grid-template-columns: 1fr; }
  .dashboard-tables .dash-two-cols { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .donut-wrap { width: min(160px, 70vw); height: min(160px, 70vw); }
}
@media (max-width: 359px) {
  .donut-wrap { width: min(140px, 75vw); height: min(140px, 75vw); }
  .dash-bar-info { flex-wrap: wrap; gap: 4px; }
}
