* { margin: 0; padding: 0; box-sizing: border-box; }

/* Inter (local, sin CDN — funciona sin internet en la red local) */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/inter-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/inter-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/inter-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/inter-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 800; font-display: swap; src: url('../fonts/inter-latin-800-normal.woff2') format('woff2'); }

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --accent: #8b5cf6;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-width: 260px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 2px 4px rgba(16, 24, 40, 0.05), 0 10px 26px rgba(16, 24, 40, 0.1);
  --shadow-lg: 0 4px 8px rgba(16, 24, 40, 0.06), 0 18px 44px rgba(16, 24, 40, 0.16);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  background-image: radial-gradient(1200px 500px at 80% -10%, rgba(99, 102, 241, 0.05), transparent);
  color: var(--gray-800);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.login-container {
  display: flex; justify-content: center; align-items: center; min-height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 55%, #8b5cf6 100%);
  position: relative; overflow: hidden;
}
.login-container::before, .login-container::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.35; pointer-events: none;
}
.login-container::before { width: 460px; height: 460px; background: #818cf8; top: -140px; right: -90px; }
.login-container::after { width: 400px; height: 400px; background: #c084fc; bottom: -160px; left: -70px; }
.login-card {
  background: white; padding: 40px; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 400px;
  animation: loginIn 0.5s ease-out; position: relative; z-index: 1;
}
@keyframes loginIn { from { transform: translateY(18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
/* Bloque de marca del login: logo de la app (HOR-FACTU) */
.login-brand { text-align: center; }
.login-brand-logo {
  display: block; width: 66px; height: 66px; margin: 0 auto 12px;
  filter: drop-shadow(0 8px 20px rgba(47, 107, 255, 0.35));
}
.login-card .login-brand h1 { margin-bottom: 6px; }
/* Pie de marca: el creador (Olazalabs) con enlace a su sitio */
.login-byline {
  display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap;
  margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--gray-200);
  text-decoration: none; font-size: 11.5px; color: var(--gray-500); letter-spacing: 0.1px;
}
.login-byline-label { font-size: 11.5px; color: inherit; }
.login-byline-rights { flex-basis: 100%; text-align: center; font-size: 10.5px; color: var(--gray-400); margin-top: 7px; letter-spacing: 0.15px; }
.login-byline-logo { display: block; height: 28px; width: auto; }
.login-byline-logo-inv { display: none; }
body.dark-mode .login-byline-logo, .desktop-chrome .login-byline-logo { display: none; }
body.dark-mode .login-byline-logo-inv, .desktop-chrome .login-byline-logo-inv { display: block; }
.login-byline:hover { color: var(--primary); opacity: .85; }
.login-sub { text-align: center; font-size: 12.5px; color: var(--gray-500); margin-top: 6px; margin-bottom: 22px; }
.login-card h1 { text-align: center; margin-bottom: 24px; color: var(--gray-800); font-size: 28px; }
#login-tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 2px solid var(--gray-200); }
#login-tabs .tab-btn { flex: 1; padding: 10px; border: none; background: none; cursor: pointer; font-size: 14px; color: var(--gray-500); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
#login-tabs .tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.login-card input { width: 100%; padding: 12px 16px; border: 1px solid var(--gray-300); border-radius: var(--radius); margin-bottom: 12px; font-size: 14px; outline: none; transition: border 0.2s; }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.error-text { color: var(--danger); font-size: 13px; margin-top: 8px; text-align: center; min-height: 20px; }
.login-card label { display: block; text-align: left; font-size: 13px; color: var(--gray-600); margin-bottom: 4px; margin-top: 8px; }
.login-card .hint { font-size: 12px; color: var(--gray-500); margin-bottom: 12px; }
.login-subheading { color: var(--gray-800); }
.login-divider { border-top: 1px solid var(--gray-200); }
.login-link { color: var(--accent, #4f7cff); }
.login-card input[readonly] { background: var(--gray-100); color: var(--gray-600); }
#activation-notice { color: var(--warning); font-weight: 600; text-align: center; margin-bottom: 12px; }
.login-card .license-info { text-align: center; font-size: 12px; color: var(--success); margin-top: 12px; font-weight: 600; display: none; }

#main-app { display: flex; height: 100vh; overflow: hidden; }

.sidebar { width: var(--sidebar-width); background: linear-gradient(180deg, #0b1120 0%, #131c31 100%); color: white; display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 100; box-shadow: 4px 0 28px rgba(2, 6, 23, 0.25); }
.sidebar::after {
  content: ''; position: absolute; top: -80px; right: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.22), transparent 70%); pointer-events: none;
}
.sidebar-header { padding: 22px 18px; border-bottom: 1px solid rgba(255,255,255,0.07); position: relative; }
.sidebar-header h2 { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; background: linear-gradient(135deg, #a5b4fc, #c4b5fd); -webkit-background-clip: text; -webkit-text-fill-color: transparent; white-space: nowrap; }
.sidebar-logo {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.5);
}
.sidebar-logo svg { width: 18px; height: 18px; }
.nav-links { list-style: none; padding: 14px 10px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.nav-links::-webkit-scrollbar { width: 4px; }
.nav-links::-webkit-scrollbar-track { background: transparent; }
.nav-links::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
.nav-links li a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  color: #94a3b8; text-decoration: none; transition: all 0.18s ease;
  font-size: 13.5px; font-weight: 500; border-radius: 10px; letter-spacing: 0.1px;
}
.nav-links li a:hover { background: rgba(255,255,255,0.07); color: #e2e8f0; transform: translateX(2px); }
.nav-links li a.active {
  background: linear-gradient(135deg, var(--primary), #7c3aed); color: white;
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; opacity: 0.75; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-links li a.active .nav-icon { opacity: 1; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.06); display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; font-size: 13px; color: #64748b; background: rgba(0,0,0,0.15); }
#license-badge { flex-basis: 100%; text-align: center; font-size: 11px; color: #94a3b8; margin-bottom: 4px; word-break: break-word; }

.content { margin-left: var(--sidebar-width); flex: 1; padding: 24px; overflow-y: auto; }
.page { display: none; }
.page.active { display: block; animation: pageIn 0.28s ease both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.btn {
  padding: 10px 20px; border: none; border-radius: var(--radius); cursor: pointer;
  font-size: 14px; font-weight: 600; letter-spacing: 0.1px; transition: all 0.18s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:active { transform: translateY(0) scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: white;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #7c3aed); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(99, 102, 241, 0.45); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 3px 10px rgba(220, 38, 38, 0.25); }
.btn-danger:hover { background: #b91c1c; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35); }
.btn-success { background: var(--success); color: white; box-shadow: 0 3px 10px rgba(16, 185, 129, 0.25); }
.btn-success:hover { background: #059669; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35); }
.btn-warning { background: var(--warning); color: white; box-shadow: 0 3px 10px rgba(245, 158, 11, 0.25); }
.btn-warning:hover { background: #d97706; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(245, 158, 11, 0.35); }
.btn-outline { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11px; }

.card {
  background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 20px; margin-bottom: 20px; border: 1px solid rgba(16, 24, 40, 0.05);
  transition: box-shadow 0.2s ease;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { font-size: 18px; color: var(--gray-800); }

.dash-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  background: linear-gradient(135deg, #0b1120 0%, #1e1b4b 55%, #312e81 100%);
  border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 20px;
  color: white; box-shadow: var(--shadow-md); position: relative; overflow: hidden;
}
.dash-hero::after {
  content: ''; position: absolute; top: -70px; right: -50px; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.35), transparent 70%); pointer-events: none;
}
.dash-hello { font-size: 12.5px; font-weight: 700; color: #a5b4fc; text-transform: uppercase; letter-spacing: 0.6px; }
.dash-title { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; margin-top: 2px; line-height: 1.15; }
.dash-sub { font-size: 12.5px; color: #c7d2fe; margin-top: 5px; }
.dash-hero-logo {
  width: 56px; height: 56px; border-radius: 16px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}
.dash-hero-logo svg { width: 28px; height: 28px; }
@media (max-width: 640px) {
  .dash-hero { padding: 16px 18px; }
  .dash-title { font-size: 19px; }
  .dash-hero-logo { width: 44px; height: 44px; border-radius: 12px; }
  .dash-hero-logo svg { width: 22px; height: 22px; }
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: white; border-radius: var(--radius-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  animation: statIn 0.45s ease both;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-card.primary .stat-icon { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); color: #4f46e5; }
.stat-card.success .stat-icon { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #059669; }
.stat-card.warning .stat-icon { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #d97706; }
.stat-card.danger .stat-icon { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #dc2626; }
.stat-card .stat-label { font-size: 11.5px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.stat-card .stat-value {
  font-size: 26px; font-weight: 800; color: var(--gray-900);
  letter-spacing: -0.6px; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat-card .stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 6px; font-weight: 500; }
@keyframes statIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; padding: 10px 16px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 14px; outline: none; }
.search-bar input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.filter-select {
  appearance: none; -webkit-appearance: none;
  padding: 8px 32px 8px 14px; cursor: pointer; outline: none;
  border: 1px solid var(--gray-300); border-radius: 999px;
  background-color: white; color: var(--gray-700);
  font-size: 13px; font-weight: 600; letter-spacing: 0.1px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}
.filter-select:hover { border-color: var(--gray-400); }
.filter-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
body.dark-mode .filter-select {
  background-color: var(--gray-700); border-color: var(--gray-600); color: var(--gray-200);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a5b4fc' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
body.dark-mode .filter-select:hover { border-color: var(--gray-500); }

.collections-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px;
  background: white; border: 1px solid var(--gray-200); border-radius: 999px;
  padding: 4px; box-shadow: var(--shadow-sm);
}
.ctab-btn {
  flex: 1; min-width: 130px; padding: 9px 16px; border: none; border-radius: 999px;
  background: transparent; cursor: pointer; font-size: 13px; font-weight: 600;
  color: var(--gray-500); transition: all 0.18s ease; white-space: nowrap;
}
.ctab-btn:hover { color: var(--primary); background: var(--primary-light); }
.ctab-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--accent)); color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
body.dark-mode .collections-tabs { background: var(--gray-800); border-color: var(--gray-700); }
body.dark-mode .ctab-btn { color: var(--gray-400); }
body.dark-mode .ctab-btn:hover { color: var(--gray-100); background: var(--gray-700); }
.coll-bucket {
  padding: 6px 10px; border-radius: 8px; display: inline-block;
  background: var(--gray-50); border: 1px solid var(--gray-200);
}
body.dark-mode .coll-bucket { background: var(--gray-700); border-color: var(--gray-600); }
@media (max-width: 640px) {
  .collections-tabs { border-radius: 14px; }
  .ctab-btn { flex: 1 1 100%; }
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
th { background: var(--gray-50); font-weight: 700; color: var(--gray-500); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; }
tr { transition: background 0.12s ease; }
tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
.table-scroll {
  overflow-x: auto; background: white; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
}
.actions { display: flex; gap: 3px; flex-wrap: nowrap; white-space: nowrap; }
.actions .btn-xs { padding: 2px 5px; font-size: 10px; line-height: 1.2; }

.badge {
  display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 11px;
  font-weight: 600; letter-spacing: 0.2px; box-shadow: inset 0 0 0 1px rgba(16, 24, 40, 0.04);
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-600); margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(2, 6, 23, 0.55); backdrop-filter: blur(3px); z-index: 1000; display: flex; justify-content: center; align-items: flex-start; padding-top: 60px; }
.modal-content {
  background: white; border-radius: var(--radius-lg); width: 100%; max-width: 1100px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}
@keyframes modalIn { from { transform: translateY(12px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--gray-200); }
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray-400); padding: 0 4px; }
.modal-close:hover { color: var(--gray-800); }
#modal-body { padding: 20px; }

/* Barra flotante de "factura minimizada": permite navegar y luego reabrir sin perder datos */
.minimized-bar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px;
  z-index: 970; display: flex; align-items: center; gap: 10px;
  max-width: calc(100vw - 24px);
  background: #fff; border: 1px solid var(--gray-200); border-radius: 999px;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.22); padding: 8px 10px 8px 16px;
  animation: minimizedIn 0.22s ease-out;
}
.minimized-bar-icon { font-size: 16px; }
.minimized-bar-title {
  font-size: 13px; font-weight: 600; color: var(--gray-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44vw;
}
.minimized-bar .btn { white-space: nowrap; }
@keyframes minimizedIn { from { transform: translateX(-50%) translateY(14px); opacity: 0; } to { transform: translateX(-50%) translateY(0); opacity: 1; } }
body.dark-mode .minimized-bar { background: var(--gray-800); border-color: var(--gray-700); }
body.dark-mode .minimized-bar-title { color: var(--gray-100); }
.device-mobile .minimized-bar {
  left: 12px; right: 12px; bottom: 74px; transform: none; max-width: none;
  border-radius: 14px; padding: 8px 10px 8px 12px;
  animation: minimizedInMob 0.22s ease-out;
}
.device-mobile .minimized-bar-title { max-width: none; flex: 1; }
@keyframes minimizedInMob { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.toast { position: fixed; bottom: 20px; right: 20px; padding: 12px 20px; border-radius: var(--radius); color: white; font-size: 14px; z-index: 2000; animation: slideIn 0.3s; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Chat */
.chat-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 950;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), #7c3aed); color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45); transition: transform 0.2s, box-shadow 0.2s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(37, 99, 235, 0.55); }
.chat-fab-badge {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--danger); color: white; font-size: 11px; font-weight: 700;
  align-items: center; justify-content: center; padding: 0 5px; border: 2px solid white;
}
.chat-panel {
  position: fixed; right: 24px; bottom: 96px; z-index: 960;
  width: 700px; height: 560px; max-height: calc(100vh - 130px);
  background: white; border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: row;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  animation: chatIn 0.22s ease-out;
}
@keyframes chatIn { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.chat-panel.maximized {
  right: 0; bottom: 0; left: 0; top: 0;
  width: 100vw; width: 100dvw; height: 100vh; height: 100dvh;
  max-height: 100vh; max-height: 100dvh;
  border-radius: 0;
}
.chat-rooms { width: 230px; display: flex; flex-direction: column; background: var(--gray-50); border-right: 1px solid var(--gray-200); min-height: 0; }
.chat-rooms-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 12px 10px; font-size: 13px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.4px; }
.chat-rooms-list { flex: 1; overflow-y: auto; min-height: 0; }
.chat-rooms-empty { padding: 16px 12px; color: var(--gray-400); font-size: 12px; text-align: center; }
.chat-room-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-left: 3px solid transparent; transition: background 0.15s; }
.chat-room-item:hover { background: var(--gray-100); }
.chat-room-item.active { background: var(--primary-light); border-left-color: var(--primary); }
.chat-room-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white;
  font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.chat-room-avatar.team { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.chat-room-info { flex: 1; min-width: 0; }
.chat-room-name { font-size: 13px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-preview { font-size: 12px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room-unread {
  flex-shrink: 0; min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px;
  background: var(--primary); color: white; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.chat-del-room {
  opacity: 0; background: none; border: none; cursor: pointer;
  padding: 3px; border-radius: 4px; flex-shrink: 0; line-height: 1; display: flex;
  transition: opacity 0.15s, background 0.15s;
}
.chat-del-room svg { width: 15px; height: 15px; display: block; }
.chat-room-item:hover .chat-del-room { opacity: 1; }
.chat-del-room:hover { background: var(--gray-200); }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.chat-scroll-btn {
  position: absolute; right: 14px; bottom: 76px; z-index: 40;
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--primary, #2563eb); color: white; box-shadow: 0 3px 10px rgba(37, 99, 235, 0.4);
  display: flex; align-items: center; justify-content: center; transition: background 0.2s, transform 0.15s;
}
.chat-scroll-btn:hover { background: var(--primary-dark, #1d4ed8); }
.chat-scroll-btn:active { transform: scale(0.92); }
.device-mobile .chat-scroll-btn { bottom: 84px; width: 40px; height: 40px; }
.chat-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; color: white;
  background: var(--primary);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.chat-title { font-size: 15px; font-weight: 700; letter-spacing: 0.3px; }
.chat-typing { display: flex; align-items: center; gap: 6px; font-size: 11px; color: rgba(255, 255, 255, 0.85); margin-top: 2px; }
.chat-typing-dots { display: inline-flex; gap: 3px; align-items: center; }
.chat-typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; animation: chatTypingDots 1.2s infinite ease-in-out; }
.chat-typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTypingDots { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }
.chat-header-actions { display: flex; gap: 6px; align-items: center; }
.chat-icon-btn {
  background: rgba(0, 0, 0, 0.08); color: var(--gray-600); border: none; border-radius: 50%;
  width: 30px; height: 30px; font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.chat-icon-btn:hover { background: rgba(0, 0, 0, 0.15); }
.chat-header .chat-icon-btn { background: rgba(255, 255, 255, 0.14); color: white; }
.chat-header .chat-icon-btn:hover { background: rgba(255, 255, 255, 0.28); }
.chat-rooms-online { border-bottom: 1px solid var(--gray-200); padding: 8px 0 6px; flex-shrink: 0; }
.chat-rooms-online-head { display: flex; align-items: center; gap: 6px; padding: 4px 12px 6px; }
.chat-online-bullet { width: 7px; height: 7px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.chat-online-label { font-size: 11px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.4px; }
.chat-online-list { display: flex; flex-direction: column; max-height: 180px; overflow-y: auto; }
.chat-online-toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px 2px; }
.chat-online-toggle-label { font-size: 12.5px; font-weight: 600; color: var(--gray-700); }
.chat-switch {
  width: 40px; height: 22px; border-radius: 12px; border: none; padding: 2px; cursor: pointer;
  background: var(--gray-300); transition: background 0.18s; display: inline-flex; align-items: center; flex-shrink: 0;
}
.chat-switch span { width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform 0.18s; }
.chat-switch.on { background: var(--primary, #2563eb); }
.chat-switch.on span { transform: translateX(18px); }
.chat-online-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; cursor: pointer; position: relative; transition: background 0.15s; }
.chat-online-item:hover { background: var(--gray-100); }
.chat-online-name { font-size: 13px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.chat-online-you { font-size: 10px; color: var(--gray-400); font-weight: 700; flex-shrink: 0; }
.chat-online-panel {
  position: absolute; top: 0; right: 0; bottom: 0; z-index: 15;
  width: 280px; max-width: 86%;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--gray-50); border-left: 1px solid var(--gray-200);
  overflow-x: hidden;
  box-shadow: -8px 0 28px rgba(15, 23, 42, 0.18);
  transform: translateX(105%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.chat-panel.online-open .chat-online-panel { transform: translateX(0); }
.chat-online-panel-head {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding: 14px 12px 8px;
}
.chat-online-panel-head .chat-icon-btn { margin-left: auto; }
.chat-online-panel .chat-online-list { flex: 1; min-height: 0; max-height: none; overflow-y: auto; overflow-x: hidden; }
.chat-online-panel .chat-online-toggle { flex-shrink: 0; padding: 8px 12px 12px; border-top: 1px solid var(--gray-200); }
.chat-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white;
  font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  user-select: none;
}
.chat-avatar.admin { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.chat-dot {
  position: absolute; bottom: -1px; right: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--success); border: 2px solid white;
}
.chat-my-avatar {
  width: 30px; height: 30px; border-radius: 50%; overflow: hidden; padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.5); background: rgba(255, 255, 255, 0.14);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.chat-profile-form { display: flex; flex-direction: column; gap: 2px; }
.chat-profile-avatar {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 8px;
  background: var(--gray-100); color: var(--gray-400); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.chat-profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.chat-profile-avatar svg { width: 38px; height: 38px; }
.chat-profile-label { font-size: 12px; font-weight: 600; color: var(--gray-500); margin: 8px 0 3px; }
.chat-profile-static { font-size: 14px; color: var(--gray-800); padding: 2px 0; }
.chat-profile-input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--gray-300); border-radius: 6px;
  font-size: 14px; background: white; color: var(--gray-800);
}
.chat-profile-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.chat-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px; background: var(--gray-50); display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.chat-day { text-align: center; font-size: 11px; color: var(--gray-400); margin: 4px 0; }
.chat-empty { text-align: center; color: var(--gray-400); font-size: 13px; margin: auto; }
.chat-msg { display: flex; flex-direction: column; max-width: 78%; }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.theirs { align-self: flex-start; align-items: flex-start; }
.chat-author { font-size: 11px; font-weight: 600; color: var(--gray-600); margin: 0 4px 3px; }
.chat-their-head { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.chat-their-head .chat-author { margin: 0; }
.chat-author-name { display: flex; align-items: center; }
.chat-author-sub { font-size: 10px; font-weight: 400; color: var(--gray-500); margin-top: 1px; }
.chat-avatar.small { width: 30px; height: 30px; font-size: 11px; }
.chat-avatar-img-wrap {
  width: 34px; height: 34px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--gray-100);
}
.chat-avatar-img-wrap.small { width: 30px; height: 30px; }
.chat-avatar-img-wrap.room { width: 40px; height: 40px; }
.chat-avatar-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-admin-tag {
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  background: var(--warning-light); color: #92400e; border-radius: 4px; padding: 1px 5px; margin-left: 3px;
}
.chat-bubble {
  padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45;
  background: white; color: var(--gray-800); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  word-break: break-word;
}
.chat-text { white-space: pre-wrap; }
.chat-msg.theirs .chat-bubble { border-bottom-left-radius: 4px; }
.chat-msg.mine .chat-bubble {
  background: var(--primary); color: white;
  border-bottom-right-radius: 4px;
}
.chat-meta { font-size: 10px; color: var(--gray-400); margin: 3px 4px 0; display: flex; align-items: center; gap: 6px; }
.chat-del-msg {
  opacity: 0; background: none; border: none; cursor: pointer;
  padding: 2px; line-height: 1; display: flex;
  transition: opacity 0.15s, transform 0.15s;
}
.chat-del-msg svg { width: 14px; height: 14px; display: block; }
.chat-msg:hover .chat-del-msg { opacity: 1; }
.chat-del-msg:hover { transform: scale(1.15); }
.chat-deleted-text { font-style: italic; opacity: 0.75; font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; }
.chat-deleted-text svg { width: 14px; height: 14px; }
.chat-inline-icon { display: inline-block; vertical-align: -4px; margin: 0 1px; }
.chat-inline-icon svg { width: 20px; height: 20px; display: block; }
.chat-checks { display: inline-flex; align-items: center; margin-left: 6px; vertical-align: -2px; }
.chat-checks .ck { width: 15px; height: 11px; display: block; }
.chat-checks.sent { color: rgba(255, 255, 255, 0.55); }
.chat-checks.delivered { color: rgba(255, 255, 255, 0.75); }
.chat-checks.read { color: #bae6fd; }
.chat-attach.image img { max-width: 220px; max-height: 200px; border-radius: 8px; display: block; cursor: pointer; }
.chat-attach-meta { font-size: 11px; opacity: 0.8; margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.chat-attach-meta span { margin-left: 6px; }
.chat-attach-meta svg { width: 13px; height: 13px; }
.chat-attach.file {
  display: flex; align-items: center; gap: 12px;
  background: rgba(0, 0, 0, 0.06); border-radius: 14px; padding: 8px 10px; margin-bottom: 6px;
}
.chat-msg.mine .chat-attach.file { background: rgba(255, 255, 255, 0.18); }
.chat-file-icon { display: flex; }
.chat-file-icon svg { width: 22px; height: 22px; }
.chat-file-info { flex: 1; min-width: 0; }
.chat-file-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-file-size { font-size: 11px; opacity: 0.75; }
.chat-pending {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 12px; background: var(--primary-light); color: var(--primary-dark);
  font-size: 12px; font-weight: 500;
}
.chat-pending > span { display: flex; align-items: center; gap: 6px; }
.chat-pending svg { width: 14px; height: 14px; }
.chat-pending-x { width: 22px; height: 22px; }
.chat-input-wrap {
  position: relative; display: flex; gap: 6px; align-items: flex-end;
  padding: 10px 12px; border-top: 1px solid var(--gray-200); background: white;
}
.chat-tool-group { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.chat-tool-btn { flex-shrink: 0; width: 32px; height: 32px; border: none; background: transparent; color: var(--gray-500); display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.chat-tool-btn:hover { background: var(--gray-200); }
#chat-mic-btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: chatMicPulse 1.1s infinite; }
@keyframes chatMicPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); } 50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); } }
.chat-recording {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: white; border-top: 1px solid var(--gray-200);
  box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.06);
  color: var(--gray-800); font-size: 12.5px; font-weight: 600;
}
.chat-rec-eq { display: inline-flex; align-items: center; gap: 2.5px; height: 20px; flex-shrink: 0; }
.chat-rec-eq i { width: 3px; height: 20px; border-radius: 2px; background: var(--danger); animation: chatEq 0.9s infinite ease-in-out; }
.chat-rec-eq i:nth-child(2) { animation-delay: 0.12s; }
.chat-rec-eq i:nth-child(3) { animation-delay: 0.24s; }
.chat-rec-eq i:nth-child(4) { animation-delay: 0.36s; }
.chat-rec-eq i:nth-child(5) { animation-delay: 0.48s; }
@keyframes chatEq { 0%, 100% { transform: scaleY(0.35); } 50% { transform: scaleY(1); } }
@keyframes chatRecBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.chat-recording.ready .chat-rec-eq i { background: var(--primary); animation: none; transform: scaleY(0.85); }
.chat-rec-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-rec-timer { font-variant-numeric: tabular-nums; color: var(--gray-500); font-weight: 500; }
.chat-rec-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-rec-cancel { width: 32px; height: 32px; border: none; color: var(--gray-500); background: var(--gray-100); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.15s; }
.chat-rec-cancel:hover { background: var(--gray-200); }
.chat-rec-send { width: 34px; height: 34px; padding: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.chat-rec-send:disabled { opacity: 0.6; cursor: default; }
.chat-media-img { position: relative; border-radius: 14px; overflow: hidden; max-width: 300px; line-height: 0; }
.chat-media-img img { display: block; width: 100%; max-width: 300px; max-height: 380px; object-fit: cover; cursor: pointer; }
.chat-media-meta { position: absolute; right: 6px; bottom: 6px; background: rgba(0, 0, 0, 0.55); color: #fff; padding: 2px 8px; border-radius: 12px; font-size: 11px; display: flex; align-items: center; gap: 5px; }
.chat-media-meta .chat-checks.read { color: #bae6fd; }
.chat-bubble.media { background: transparent; padding: 0; }
.chat-msg.mine .chat-bubble.media { background: transparent; }
.chat-voice { display: flex; align-items: center; gap: 9px; min-width: 230px; max-width: 270px; }
.chat-voice-play { width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; background: var(--primary); color: #fff; flex-shrink: 0; transition: transform 0.15s; }
.chat-voice-play:hover { transform: scale(1.06); }
.chat-msg.mine .chat-voice-play { background: #fff; color: var(--primary); }
.chat-voice-wave { display: flex; align-items: center; gap: 2px; height: 30px; flex: 1; min-width: 0; cursor: pointer; }
.chat-voice-wave:hover .chat-voice-bar { opacity: 0.75; }
.chat-voice-wave:active { opacity: 0.85; }
.chat-voice-bar { width: 3px; border-radius: 2px; background: currentColor; opacity: 0.4; transform-origin: center; }
.chat-voice-bar.played { opacity: 1; }
.chat-voice-dur { font-size: 11px; opacity: 0.85; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.chat-voice.playing .chat-voice-bar { animation: chatVoiceAnim 0.9s infinite ease-in-out; }
@keyframes chatVoiceAnim { 0%, 100% { transform: scaleY(0.55); } 50% { transform: scaleY(1); } }
.chat-file-type { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; letter-spacing: 0.3px; flex-shrink: 0; transition: transform 0.15s; }
.chat-file-type-link { display: flex; text-decoration: none; }
.chat-file-type-link:hover .chat-file-type { transform: scale(1.06); }
.chat-file-type.pdf { background: #fee2e2; color: #dc2626; }
.chat-file-type.word { background: #e0e7ff; color: #6366f1; }
.chat-file-type.excel { background: #d1fae5; color: #059669; }
.chat-file-type.ppt { background: #ffedd5; color: #ea580c; }
.chat-file-type.zip { background: #fef9c3; color: #ca8a04; }
.chat-file-type.text { background: #e5e7eb; color: #4b5563; }
.chat-file-type.gen { background: #e0e7ff; color: #4f46e5; }
.chat-call-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px; background: linear-gradient(135deg, #1d4ed8, #0ea5e9); color: #fff;
  font-size: 13px; flex-shrink: 0;
}
.chat-call-info { display: flex; align-items: center; gap: 9px; min-width: 0; }
.chat-call-dot { width: 8px; height: 8px; border-radius: 50%; background: #86efac; animation: chatRecBlink 1.2s infinite; flex-shrink: 0; }
.chat-call-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
#chat-call-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-call-time { font-size: 11px; opacity: 0.85; font-variant-numeric: tabular-nums; }
.chat-call-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.chat-call-action { width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, 0.18); color: #fff; }
.chat-call-action:hover { background: rgba(255, 255, 255, 0.3); }
.chat-call-action.active { background: rgba(255, 255, 255, 0.95); color: #1d4ed8; }
.chat-call-hangup { background: var(--danger); }
.chat-call-hangup:hover { background: #dc2626; }
.chat-call-video-layer {
  position: relative; flex: 1; min-height: 0;
  background: #0f172a; overflow: hidden;
}
.chat-call-video-layer video { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-call-video-waiting {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255, 255, 255, 0.85); font-size: 14px; text-align: center; padding: 20px;
  background: linear-gradient(160deg, #1d4ed8, #0f172a);
}
#chat-call-video-local {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  width: 110px; height: 148px; border-radius: 12px; object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.75); background: #1e293b;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.chat-call-incoming {
  position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(3px);
}
.chat-call-incoming-card {
  width: 300px; max-width: 88vw; background: white; border-radius: 18px; padding: 26px 22px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); animation: chatCallPop 0.25s ease-out;
}
@keyframes chatCallPop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chat-call-incoming-avatar { margin-bottom: 10px; }
.chat-call-incoming-avatar .chat-avatar { width: 72px; height: 72px; font-size: 26px; }
.chat-call-incoming-name { font-size: 17px; font-weight: 700; color: var(--gray-800); }
.chat-call-incoming-sub { font-size: 13px; color: var(--gray-500); }
.chat-call-incoming-btns { display: flex; gap: 34px; margin-top: 18px; }
.chat-call-big { width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; }
.chat-call-decline { background: var(--danger); }
.chat-call-decline:hover { background: #dc2626; }
.chat-call-accept { background: var(--success); }
.chat-call-accept:hover { background: #16a34a; }
body.dark-mode .chat-call-incoming-card { background: var(--gray-800); }
body.dark-mode .chat-call-incoming-name { color: var(--gray-100); }
body.dark-mode .chat-call-incoming-sub { color: var(--gray-400); }
body.dark-mode .chat-recording { background: var(--gray-800); border-top-color: var(--gray-700); color: var(--gray-100); }
body.dark-mode .chat-rec-cancel { background: var(--gray-700); color: var(--gray-300); }
body.dark-mode .chat-rec-cancel:hover { background: var(--gray-600); }
.chat-icon-btn svg { width: 17px; height: 17px; }
.chat-input {
  flex: 1; resize: none; border: 1px solid var(--gray-300); border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; font-family: inherit; outline: none; max-height: 96px;
  transition: border 0.2s, box-shadow 0.2s;
}
.chat-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.chat-send { padding: 9px 16px; align-self: stretch; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.chat-send svg { width: 16px; height: 16px; flex-shrink: 0; }
.chat-emoji-picker {
  position: absolute; bottom: calc(100% + 8px); right: 12px; z-index: 20;
  width: 292px; max-height: 210px; overflow-y: auto; flex-wrap: wrap; gap: 2px;
  background: white; border: 1px solid var(--gray-200); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18); padding: 8px;
}
.chat-emoji { display: flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 4px; border-radius: 6px; cursor: pointer; }
.chat-emoji svg { width: 22px; height: 22px; }
.chat-emoji:hover { background: var(--gray-100); }
.chat-user-list { max-height: 420px; overflow-y: auto; }
.chat-user-row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; cursor: pointer; border-bottom: 1px solid var(--gray-100); border-radius: 8px; }
.chat-user-row:hover { background: var(--gray-50); }
.chat-user-name { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.chat-user-sub { font-size: 12px; color: var(--gray-500); }

@media (max-width: 700px) {
  .chat-panel { right: 0; left: 0; bottom: 0; width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; }
  .chat-rooms { width: 165px; }
  .chat-fab { right: 14px; bottom: 14px; }
}
@media (max-width: 420px) {
  .chat-rooms { width: 130px; }
  .chat-room-avatar { width: 34px; height: 34px; font-size: 12px; }
}

.chart-container { position: relative; height: 300px; margin-top: 16px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state p { margin-top: 8px; font-size: 14px; }

.item-row { display: grid; grid-template-columns: 200px 150px 1fr 1fr 1fr 1fr auto; gap: 8px; align-items: end; margin-bottom: 8px; }
.item-row input, .item-row select { padding: 8px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 13px; }
.inv-item-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--gray-300); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.15); z-index: 100; max-height: 200px; overflow-y: auto; }
.inv-dropdown-item { padding: 8px 10px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--gray-100); }
.inv-dropdown-item:hover, .inv-dropdown-item.active { background: var(--primary-light); }
.client-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid var(--gray-300); border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.15); z-index: 100; max-height: 220px; overflow-y: auto; }
.client-dropdown-item { padding: 7px 10px; cursor: pointer; font-size: 12px; border-bottom: 1px solid var(--gray-100); line-height: 1.4; }
.client-dropdown-item:hover, .client-dropdown-item.active { background: var(--primary-light); }

@media (max-width: 768px) {
  .sidebar { width: 64px; }
  .sidebar-header h2, .nav-links li a span:not(.nav-icon), .sidebar-footer span { display: none; }
  .nav-links li a { justify-content: center; padding: 12px; }
  .nav-links li a .nav-icon { font-size: 18px; opacity: 1; }
  .sidebar-header { padding: 16px 8px; text-align: center; }
  .sidebar-footer { justify-content: center; padding: 12px 8px; }
  .content { margin-left: 64px; padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

.logo-preview { max-height: 80px; margin-bottom: 8px; display: block; border-radius: var(--radius); border: 1px solid var(--gray-200); padding: 4px; }
input[type="file"] { padding: 8px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 13px; width: 100%; }
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 700px; }

/* Dark Mode */
body.dark-mode {
  background: var(--gray-900);
  background-image: radial-gradient(1200px 500px at 80% -10%, rgba(99, 102, 241, 0.09), transparent);
  color: var(--gray-200);
}
body.dark-mode .login-card { background: var(--gray-800); }
body.dark-mode .login-card h1 { color: var(--gray-100); }
body.dark-mode .login-card input { background: var(--gray-700); border-color: var(--gray-600); color: white; }
body.dark-mode .login-card label { color: var(--gray-300); }
body.dark-mode .login-card input[readonly] { background: var(--gray-700); color: var(--gray-300); }
body.dark-mode .btn-outline { background: var(--gray-700); color: var(--gray-200); border-color: var(--gray-600); }
body.dark-mode .btn-outline:hover { background: var(--gray-600); }
body.dark-mode .card { background: var(--gray-800); box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
body.dark-mode .card-header h2 { color: var(--gray-100); }
body.dark-mode .stat-card { background: var(--gray-800); }
body.dark-mode .stat-card .stat-value { color: var(--gray-100); }
body.dark-mode th { background: var(--gray-700); color: var(--gray-300); }
body.dark-mode td { border-bottom-color: var(--gray-700); color: var(--gray-300); }
body.dark-mode tr:hover { background: var(--gray-700); }
body.dark-mode .search-bar input { background: var(--gray-700); border-color: var(--gray-600); color: white; }
body.dark-mode .form-group label { color: var(--gray-300); }
body.dark-mode .form-group input, body.dark-mode .form-group select, body.dark-mode .form-group textarea {
  background: var(--gray-700); border-color: var(--gray-600); color: white;
}
body.dark-mode .modal-content { background: var(--gray-800); }
body.dark-mode .modal-header { border-bottom-color: var(--gray-700); }
body.dark-mode .modal-header h3 { color: var(--gray-100); }
body.dark-mode .modal-close { color: var(--gray-400); }
body.dark-mode .modal-close:hover { color: var(--gray-100); }
body.dark-mode .inv-item-dropdown { background: var(--gray-700); border-color: var(--gray-600); }
body.dark-mode .inv-dropdown-item { color: var(--gray-200); border-bottom-color: var(--gray-600); }
body.dark-mode .inv-dropdown-item:hover, body.dark-mode .inv-dropdown-item.active { background: var(--primary-dark); color: white; }
body.dark-mode .client-dropdown { background: var(--gray-700); border-color: var(--gray-600); }
body.dark-mode .client-dropdown-item { color: var(--gray-200); border-bottom-color: var(--gray-600); }
body.dark-mode .client-dropdown-item:hover, body.dark-mode .client-dropdown-item.active { background: var(--primary-dark); color: white; }
body.dark-mode .item-row input, body.dark-mode .item-row select { background: var(--gray-700); border-color: var(--gray-600); color: white; }
body.dark-mode input[type="file"] { background: var(--gray-700); border-color: var(--gray-600); color: white; }
body.dark-mode .badge-success { background: #064e3b; color: #6ee7b7; }
body.dark-mode .badge-warning { background: #78350f; color: #fcd34d; }
body.dark-mode .badge-danger { background: #7f1d1d; color: #fca5a5; }
body.dark-mode .badge-primary { background: #312e81; color: #a5b4fc; }
body.dark-mode .badge-secondary { background: #334155; color: #cbd5e1; }
body.dark-mode .chat-panel { background: var(--gray-800); }
body.dark-mode .chat-rooms { background: var(--gray-800); border-right-color: var(--gray-700); }
body.dark-mode .chat-rooms-header { color: var(--gray-400); }
body.dark-mode .chat-room-item:hover { background: var(--gray-700); }
body.dark-mode .chat-room-item.active { background: #312e81; border-left-color: var(--primary); }
body.dark-mode .chat-room-name { color: var(--gray-100); }
body.dark-mode .chat-room-preview { color: var(--gray-400); }
body.dark-mode .chat-del-room:hover { background: var(--gray-600); }
body.dark-mode .chat-messages { background: var(--gray-900); }
body.dark-mode .chat-bubble { background: var(--gray-700); color: var(--gray-100); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
body.dark-mode .chat-msg.mine .chat-bubble { background: var(--primary); }
body.dark-mode .chat-checks.read { color: #a5b4fc; }
body.dark-mode .chat-attach.file { background: rgba(0, 0, 0, 0.3); }
body.dark-mode .chat-msg.mine .chat-attach.file { background: rgba(0, 0, 0, 0.25); }
body.dark-mode .chat-input-wrap { background: var(--gray-800); border-top-color: var(--gray-700); }
body.dark-mode .chat-input { background: var(--gray-700); border-color: var(--gray-600); color: white; }
body.dark-mode .chat-input:focus { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35); }
body.dark-mode .chat-tool-btn { background: transparent; border: none; color: var(--gray-200); }
body.dark-mode .chat-tool-btn:hover { background: var(--gray-600); }
body.dark-mode .chat-pending { background: #312e81; color: #a5b4fc; }
body.dark-mode .chat-emoji-picker { background: var(--gray-700); border-color: var(--gray-600); }
body.dark-mode .chat-emoji:hover { background: var(--gray-600); }
body.dark-mode .chat-online-panel { background: var(--gray-800); border-color: var(--gray-700); }
body.dark-mode .chat-online-panel .chat-online-toggle { border-top-color: var(--gray-700); }
body.dark-mode .chat-online-name { color: var(--gray-100); }
body.dark-mode .chat-online-you { color: var(--gray-400); }
body.dark-mode .chat-online-label { color: #94a3b8; }
body.dark-mode .chat-online-toggle-label { color: var(--gray-200); }
body.dark-mode .chat-online-item:hover { background: var(--gray-700); }
body.dark-mode .chat-user-row { border-bottom-color: var(--gray-700); }
body.dark-mode .chat-user-row:hover { background: var(--gray-700); }
body.dark-mode .chat-user-name { color: var(--gray-100); }
body.dark-mode .chat-author { color: var(--gray-300); }
body.dark-mode .chat-author-sub { color: var(--gray-400); }
body.dark-mode .chat-profile-avatar { background: var(--gray-700); }
body.dark-mode .chat-profile-static { color: var(--gray-100); }
body.dark-mode .chat-profile-input { background: var(--gray-700); border-color: var(--gray-600); color: var(--gray-100); }
body.dark-mode .chat-fab-badge { border-color: var(--gray-800); }

/* ============================================
   CHAT ESTILO WHATSAPP (layout, no colores)
   ============================================ */
.chat-rooms-search {
  display: flex; align-items: center; gap: 8px; margin: 0 12px 10px;
  background: var(--gray-100); border-radius: 20px; padding: 7px 12px; color: var(--gray-400);
}
.chat-rooms-search input {
  flex: 1; border: none; background: none; outline: none; font-size: 13px;
  color: var(--gray-800); font-family: inherit;
}
.chat-rooms-search svg { flex-shrink: 0; }
.chat-room-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-room-time { font-size: 11px; color: var(--gray-400); flex-shrink: 0; }
.chat-room-preview-line { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 1px; }
.chat-room-info { min-width: 0; }
.chat-room-name { font-size: 14px; }

.chat-head-user { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.chat-head-avatar { flex-shrink: 0; display: flex; }
.chat-head-text { min-width: 0; }
.chat-avatar.head, .chat-avatar-img-wrap.head { width: 38px; height: 38px; font-size: 14px; }

.chat-messages {
  background-color: var(--gray-50);
  background-image: radial-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px);
  background-size: 16px 16px;
}
.chat-bubble { padding: 7px 11px 9px; line-height: 1.45; }
.chat-bubble-meta {
  float: right; display: flex; align-items: center; gap: 3px;
  font-size: 10.5px; line-height: 1; color: var(--gray-400);
  margin: 6px -4px -4px 10px; user-select: none;
}
.chat-msg.mine .chat-bubble-meta { color: rgba(255, 255, 255, 0.72); }
.chat-bubble-time { white-space: nowrap; }

.chat-input-wrap { align-items: center; gap: 6px; padding: 10px 14px; }
.chat-tool-group {
  display: flex; align-items: center; gap: 2px; flex-shrink: 0;
  background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: 20px; padding: 2px;
}
.chat-tool-btn { width: 32px; height: 32px; border-radius: 50%; border: none; background: transparent; color: var(--gray-500); }
.chat-tool-btn:hover { background: var(--gray-200); color: var(--primary); }
.chat-input-wrap .chat-tool-group {
  overflow: hidden; max-width: 120px; opacity: 1;
  transition: max-width 0.3s ease, opacity 0.22s ease, padding 0.3s ease, border-width 0.3s ease, margin-right 0.3s ease;
}
.chat-input-wrap.typing .chat-tool-group {
  max-width: 0; opacity: 0; padding: 0; border-width: 0; margin-right: -6px; pointer-events: none;
}
.chat-input { border-radius: 22px; padding: 10px 16px; }
.chat-send { border-radius: 22px; }
.chat-emoji { font-size: 20px; }

body.dark-mode .chat-rooms-search { background: var(--gray-700); color: var(--gray-400); }
body.dark-mode .chat-rooms-search input { color: white; }
body.dark-mode .chat-room-time { color: var(--gray-500); }
body.dark-mode .chat-tool-group { background: var(--gray-800); border-color: var(--gray-600); }
body.dark-mode .chat-tool-btn { background: transparent; border: none; color: var(--gray-400); }
body.dark-mode .chat-tool-btn:hover { background: var(--gray-600); color: #a5b4fc; }
body.dark-mode .chat-messages {
  background-color: var(--gray-900);
  background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 16px 16px;
}

/* Respuestas, edicion y acciones de mensaje */
.chat-quote {
  border-left: 3px solid var(--primary);
  background: rgba(15, 23, 42, 0.05);
  border-radius: 6px;
  padding: 4px 9px;
  margin: 0 0 6px;
  cursor: pointer;
  min-width: 150px;
  max-width: 260px;
}
.chat-quote-author { font-size: 11px; font-weight: 700; color: var(--primary); line-height: 1.3; }
.chat-quote-text { font-size: 12px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.chat-msg.mine .chat-quote { background: rgba(255, 255, 255, 0.16); border-left-color: rgba(255, 255, 255, 0.9); }
.chat-msg.mine .chat-quote-author { color: #fff; }
.chat-msg.mine .chat-quote-text { color: rgba(255, 255, 255, 0.85); }
.chat-edited-tag { font-size: 10px; opacity: 0.6; margin-right: 5px; font-style: italic; }
.chat-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.chat-msg:hover .chat-actions { opacity: 1; }
.chat-act-btn {
  background: none; border: none; cursor: pointer; padding: 3px; border-radius: 4px;
  color: var(--gray-500); display: flex; line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.chat-act-btn:hover { background: var(--gray-200); color: var(--primary); }
.chat-act-btn svg { width: 14px; height: 14px; display: block; }

.chat-replybar {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; background: var(--gray-50); color: var(--gray-600);
  border-top: 1px solid var(--gray-200); font-size: 12px;
}
.chat-replybar-label {
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: flex; align-items: center; gap: 5px; flex-shrink: 0; min-width: 0;
}
.chat-replybar-label svg { width: 13px; height: 13px; flex-shrink: 0; }
.chat-replybar-label b { font-weight: 700; color: var(--primary); }
.chat-replybar-preview { flex: 1; min-width: 0; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-replybar-x { background: none; border: none; cursor: pointer; font-size: 17px; color: var(--gray-400); line-height: 1; flex-shrink: 0; }
.chat-replybar-x:hover { color: var(--gray-700); }

.chat-input { scrollbar-width: none; -ms-overflow-style: none; }
.chat-input::-webkit-scrollbar { display: none; }

/* Scrollbars modernos azul/morado: aparecen solo donde esta el mouse */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: transparent; }
*:hover::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #6366f1, #8b5cf6); }
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, #818cf8, #a78bfa); }
html::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb { background: transparent !important; }
* { scrollbar-width: thin; scrollbar-color: transparent transparent; }
*:hover { scrollbar-color: #7c3aed transparent; }
html, body { scrollbar-color: transparent transparent !important; }
.device-mobile::-webkit-scrollbar-thumb,
.device-mobile *::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #6366f1, #8b5cf6); }
.device-mobile, .device-mobile * { scrollbar-color: #8b5cf6 transparent; }

/* Indicador de deslizar para responder */
.chat-swipe-indicator {
  position: fixed; z-index: 980;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--gray-300); color: white;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transition: opacity 0.08s linear;
  will-change: left, top, opacity;
}
.chat-swipe-indicator svg { width: 22px; height: 22px; }
.chat-swipe-indicator.ready {
  background: var(--success);
  animation: chatSwipePulse 0.5s ease;
}
@keyframes chatSwipePulse {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.chat-msg { -webkit-touch-callout: none; user-select: none; }

/* Menu contextual (pulsar y mantener) */
.chat-msg-menu {
  position: fixed; z-index: 990; min-width: 190px;
  background: white; border: 1px solid var(--gray-200); border-radius: 12px;
  box-shadow: 0 16px 44px rgba(15, 23, 42, 0.28);
  padding: 6px; overflow: hidden;
  animation: chatMenuIn 0.12s ease-out;
}
@keyframes chatMenuIn { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.chat-msg-menu-name {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--gray-400); padding: 6px 10px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-msg-menu-btn {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 9px 10px; border: none; background: none; cursor: pointer;
  font-size: 13.5px; font-family: inherit; color: var(--gray-800);
  border-radius: 8px; transition: background 0.12s, color 0.12s;
}
.chat-msg-menu-btn svg { width: 16px; height: 16px; color: var(--gray-500); flex-shrink: 0; }
.chat-msg-menu-btn:hover { background: var(--gray-100); color: var(--primary); }
.chat-msg-menu-btn:hover svg { color: var(--primary); }
.chat-msg-menu-btn.danger { color: var(--danger); }
.chat-msg-menu-btn.danger svg { color: var(--danger); }
.chat-msg-menu-btn.danger:hover { background: var(--danger); color: white; }
.chat-msg-menu-btn.danger:hover svg { color: white; }
.chat-msg-reactions {
  display: flex; gap: 2px; padding: 4px 8px 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-100); margin-bottom: 4px;
}
.chat-msg-emoji {
  width: 30px; height: 30px; border: none; background: none; cursor: pointer;
  font-size: 18px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, transform 0.12s;
}
.chat-msg-emoji:hover { background: var(--gray-100); transform: scale(1.18); }
.chat-reactions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; padding: 0 6px; }
.chat-reaction-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(79, 70, 229, 0.08); border: 1px solid rgba(79, 70, 229, 0.18);
  color: var(--gray-700); border-radius: 999px; padding: 2px 8px;
  font-size: 12.5px; cursor: pointer; transition: background 0.12s, transform 0.12s;
}
.chat-reaction-chip span { font-size: 11px; font-weight: 700; opacity: 0.85; }
.chat-reaction-chip:hover { background: rgba(79, 70, 229, 0.16); transform: scale(1.06); }
.chat-reaction-chip.mine { background: rgba(79, 70, 229, 0.2); border-color: var(--primary); color: var(--primary); }
.chat-msg.mine .chat-reactions { justify-content: flex-end; }
body.dark-mode .chat-msg-emoji:hover { background: var(--gray-600); }
body.dark-mode .chat-reaction-chip { background: rgba(147, 197, 253, 0.1); border-color: rgba(147, 197, 253, 0.25); color: var(--gray-200); }
body.dark-mode .chat-reaction-chip:hover { background: rgba(147, 197, 253, 0.2); }
body.dark-mode .chat-reaction-chip.mine { background: rgba(147, 197, 253, 0.22); border-color: #a5b4fc; color: #a5b4fc; }
body.dark-mode .chat-msg-reactions { border-bottom-color: var(--gray-600); }

body.dark-mode .chat-swipe-indicator { background: var(--gray-600); }
body.dark-mode .chat-swipe-indicator.ready { background: #16a34a; }
body.dark-mode .chat-msg-menu { background: var(--gray-700); border-color: var(--gray-600); }
body.dark-mode .chat-msg-menu-name { color: var(--gray-400); }
body.dark-mode .chat-msg-menu-btn { color: var(--gray-100); }
body.dark-mode .chat-msg-menu-btn svg { color: var(--gray-400); }
body.dark-mode .chat-msg-menu-btn:hover { background: var(--gray-600); color: #a5b4fc; }
body.dark-mode .chat-msg-menu-btn:hover svg { color: #a5b4fc; }
body.dark-mode .chat-msg-menu-btn.danger { color: #fca5a5; }
body.dark-mode .chat-msg-menu-btn.danger svg { color: #fca5a5; }
body.dark-mode .chat-msg-menu-btn.danger:hover { background: var(--danger); color: white; }
body.dark-mode .chat-msg-menu-btn.danger:hover svg { color: white; }

body.dark-mode .chat-quote { background: rgba(0, 0, 0, 0.25); border-left-color: #a5b4fc; }
body.dark-mode .chat-quote-author { color: #a5b4fc; }
body.dark-mode .chat-quote-text { color: var(--gray-400); }
body.dark-mode .chat-msg.mine .chat-quote { background: rgba(0, 0, 0, 0.25); border-left-color: rgba(255, 255, 255, 0.6); }
body.dark-mode .chat-msg.mine .chat-quote-author { color: rgba(255, 255, 255, 0.95); }
body.dark-mode .chat-msg.mine .chat-quote-text { color: rgba(255, 255, 255, 0.75); }
body.dark-mode .chat-act-btn { color: var(--gray-400); }
body.dark-mode .chat-act-btn:hover { background: var(--gray-600); color: #a5b4fc; }
body.dark-mode .chat-replybar { background: var(--gray-800); border-top-color: var(--gray-700); color: var(--gray-300); }
body.dark-mode .chat-replybar-label b { color: #a5b4fc; }
body.dark-mode .chat-replybar-preview { color: var(--gray-400); }
body.dark-mode .chat-replybar-x { color: var(--gray-500); }
body.dark-mode .chat-replybar-x:hover { color: var(--gray-200); }


.theme-toggle {
  background: rgba(255,255,255,0.07); color: #94a3b8; width: 36px; height: 36px; padding: 0;
  border-radius: 10px; cursor: pointer; transition: all 0.2s;
  border: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,0.16); color: white; transform: translateY(-1px); }
.theme-toggle svg { width: 17px; height: 17px; }
.theme-toggle .icon-moon { display: none; }
body.dark-mode .theme-toggle .icon-sun { display: none; }
body.dark-mode .theme-toggle .icon-moon { display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.skeleton { animation: skeleton-pulse 1.5s ease-in-out infinite; background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100, #e5e7eb) 50%, var(--gray-200) 75%); background-size: 200% 100%; border-radius: var(--radius); }
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.short { width: 60%; }
.skeleton-text.medium { width: 80%; }
.skeleton-row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--gray-200); }
.skeleton-row .skeleton { flex-shrink: 0; }
.skeleton-table { display: flex; flex-direction: column; gap: 0; }
.skeleton-header { display: flex; gap: 12px; padding: 10px 0; border-bottom: 2px solid var(--gray-300); margin-bottom: 4px; }
.skeleton-header .skeleton { height: 16px; flex: 1; }
.skeleton-loading-msg { text-align: center; margin-top: 12px; color: var(--gray-500, #6b7280); font-size: 14px; animation: skeleton-pulse 1.5s ease-in-out infinite; }
@keyframes skeleton-pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }

.closure-report { font-family: 'Segoe UI', system-ui, sans-serif; width: 100%; }
@media (min-width: 1200px) {
  .closure-report { max-width: 1100px; margin: 0 auto; }
}
.closure-header { text-align: center; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 3px double var(--gray-300); }
.closure-header h2 { font-size: 22px; letter-spacing: 1.5px; color: var(--primary); margin-bottom: 2px; }
.closure-header h3 { font-size: 16px; color: var(--gray-700); font-weight: 600; }
.closure-period { font-size: 13px; color: var(--gray-500); margin-top: 4px; }
.closure-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.cstat { background: var(--gray-50); border-radius: 8px; padding: 14px 12px; text-align: center; border-left: 4px solid var(--gray-300); box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.cstat.primary { border-left-color: var(--primary); }
.cstat.success { border-left-color: var(--success); }
.cstat.warning { border-left-color: var(--warning); }
.cstat.profit { border-left-color: var(--pc, var(--gray-500)); }
.cstat-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--gray-500); margin-bottom: 4px; }
.cstat-value { display: block; font-size: 20px; font-weight: 700; color: var(--gray-800); }
.cstat-sub { display: block; font-size: 11px; color: var(--gray-500); margin-top: 3px; }
.cpos { color: var(--success) !important; }
.cneg { color: var(--danger) !important; }
.closure-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.closure-card { background: white; border-radius: 8px; padding: 16px 18px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid var(--gray-200); page-break-inside: avoid; overflow-x: auto; }
.closure-card h3 { font-size: 15px; color: var(--primary); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 2px solid var(--gray-100); }
#closure-outer-card { padding: 0; overflow: hidden; }
#closure-outer-card .card-header { padding: 16px 22px; margin: 0; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
#closure-content { padding: 16px 16px 12px; }
.ctable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ctable thead th { background: var(--gray-50); color: var(--gray-600); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; padding: 8px 8px; text-align: left; border-bottom: 2px solid var(--gray-200); font-weight: 600; }
.ctable tbody td { padding: 8px 8px; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
.ctable tbody tr:last-child td { border-bottom: none; }
.ctable tbody tr:hover { background: var(--gray-50); }
.cempty { text-align: center; color: var(--gray-400); padding: 24px; font-size: 14px; }
.closure-footer { text-align: center; padding: 16px; color: var(--gray-400); font-size: 12px; border-top: 1px solid var(--gray-200); margin-top: 8px; }

@media print {
  @page { size: landscape; margin: 10mm; }
  .sidebar, .card-header .btn, .search-bar, #closure-month, #closure-year, .toast { display: none !important; }
  .content { margin-left: 0 !important; padding: 0 !important; overflow: visible !important; height: auto !important; }
  #main-app { height: auto !important; overflow: visible !important; margin-top: 0 !important; }
  #desktop-titlebar { display: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; page-break-inside: avoid; }
  .stat-card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: white !important; font-size: 12pt; }
  #page-closure { display: block !important; }
  .closure-card { box-shadow: none !important; border: 1px solid #ccc !important; page-break-inside: avoid; overflow: visible !important; }
  .closure-stats { page-break-inside: avoid; }
  .ctable { font-size: 8pt; width: 100%; }
  .ctable thead th { padding: 4px 5px; font-size: 7.5pt; white-space: nowrap; }
  .ctable tbody td { padding: 4px 5px; white-space: nowrap; }
  .closure-header h2 { font-size: 18pt; }
  .closure-header h3 { font-size: 13pt; }
  .cstat-value { font-size: 14pt; }
  .closure-grid-2 { display: block; }
  .closure-grid-2 .closure-card { page-break-inside: avoid; margin-bottom: 10px; }
  .closure-card h3 { font-size: 11pt; }

  /* Cierre acumulado desde Informes: imprime solo el informe, no la app */
  body.printing-informes-close #page-closure { display: none !important; }
  body.printing-informes-close #page-informes { display: block !important; }
  body.printing-informes-close #page-informes > .card { border: none !important; box-shadow: none !important; padding: 0 !important; margin: 0 !important; }
  body.printing-informes-close #page-informes > .card > .card-header { display: none !important; }
  body.printing-informes-close .inf-close-toolbar { display: none !important; }
  body.printing-informes-close #informes-content { padding: 0 !important; }
}

/* ============================================
   VERSION MOVIL TIPO APP (diseno corporativo)
   ============================================ */
#mobile-shell { display: none; }

.device-mobile .sidebar { display: none; }
.device-mobile .content { margin-left: 0; width: 100%; padding: 66px 14px 88px; }
.device-mobile #mobile-shell { display: block; }
.device-mobile .chat-fab { display: none; }
.device-mobile .chat-online-list { max-height: 132px; }
.device-mobile .chat-online-item { padding: 8px 14px; }
.device-mobile .chat-online-name { font-size: 13.5px; }

/* ---------- App Bar ---------- */
#mobile-shell { position: fixed; inset: 0; z-index: 700; pointer-events: none; }
#mobile-shell > * { pointer-events: auto; }
.mob-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 800;
  height: 56px; padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 8px;
  background: white; color: var(--gray-800);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
}
.mob-icon-btn {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--gray-200);
  background: var(--gray-50); color: var(--gray-600); font-size: 17px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.mob-icon-btn:hover { background: var(--gray-100); color: var(--primary); }
.mob-title { flex: 1; min-width: 0; text-align: left; padding-left: 4px; }
.mob-app-name { display: block; font-size: 12px; font-weight: 800; letter-spacing: 1.1px; color: var(--primary); }
.mob-page-title { display: block; font-size: 15px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

/* ---------- Bottom Navigation ---------- */
.mob-bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 800;
  height: 62px; padding-bottom: env(safe-area-inset-bottom);
  display: flex; background: white; border-top: 1px solid var(--gray-200);
  box-shadow: 0 -2px 14px rgba(15, 23, 42, 0.05);
}
.mob-nav-btn {
  flex: 1; border: none; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--gray-400); font-size: 11px; font-weight: 600; letter-spacing: 0.2px;
  transition: color 0.15s;
}
.mob-nav-btn:hover { color: var(--primary); }
.mob-nav-btn.active { color: var(--primary); }
.mob-nav-btn.active .mob-nav-icon { background: var(--primary-light); border-radius: 10px; padding: 4px 10px; }
.mob-nav-icon { font-size: 20px; line-height: 1; display: flex; }

/* ---------- Home ---------- */
#mob-home { padding: 6px 2px 14px; }
.mob-home-head { padding: 8px 4px 16px; }
.mob-home-head h2 { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gray-400); }
.mob-home-user { font-size: 20px; font-weight: 700; color: var(--gray-900); margin-top: 3px; }
.mob-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.mob-mod-card {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px;
  padding: 18px 8px 14px; background: white; border: 1px solid var(--gray-200);
  border-radius: 16px; cursor: pointer; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: transform 0.12s, box-shadow 0.12s;
}
.mob-mod-card:active { transform: scale(0.96); box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08); }
.mob-mod-icon {
  width: 44px; height: 44px; border-radius: 12px; font-size: 20px; line-height: 1;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.mob-mod-label { font-size: 11.5px; font-weight: 600; color: var(--gray-700); text-align: center; line-height: 1.25; }

/* ---------- Chat movil ---------- */
.chat-rooms-toggle { display: none; }
.device-mobile .chat-rooms-toggle { display: flex; }
.device-mobile .chat-panel { inset: 0; width: 100%; height: 100vh; height: 100dvh; max-height: 100dvh; border-radius: 0; }
.device-mobile .chat-main { width: 100%; }
.device-mobile .chat-rooms {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 12;
  width: 82%; max-width: 320px; border-right: none;
  box-shadow: 8px 0 28px rgba(15, 23, 42, 0.22);
  transform: translateX(-102%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.device-mobile .chat-panel.rooms-open .chat-rooms { transform: translateX(0); }
.device-mobile .chat-header { flex-wrap: nowrap; gap: 6px; padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top)); }
.device-mobile .chat-header > div:first-child { min-width: 0; }
.device-mobile .chat-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-mobile .chat-online-label { font-size: 10.5px; }
.device-mobile .chat-messages { padding: 14px 12px; }
.device-mobile .chat-msg { max-width: 85%; }
.device-mobile .chat-input-wrap { padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
.device-mobile .chat-send { width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.device-mobile .chat-send-label { display: none; }
.device-mobile #chat-maximize-btn { display: none; }
.device-mobile .chat-header-actions { gap: 4px; }
.device-mobile .chat-messages { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.device-mobile .chat-emoji-picker { right: 10px; width: calc(100% - 20px); max-width: 320px; }
.device-mobile .chat-online-panel { width: 82%; max-width: 320px; border-left: none; box-shadow: -8px 0 28px rgba(15, 23, 42, 0.22); }

/* ---------- Modales movil ---------- */
.device-mobile .modal { padding: 0; align-items: stretch; }
.device-mobile .modal-content { width: 100%; max-width: 100%; max-height: 100vh; max-height: 100dvh; height: 100vh; height: 100dvh; border-radius: 0; display: flex; flex-direction: column; }
.device-mobile .modal-header { padding-top: calc(14px + env(safe-area-inset-top)); flex-shrink: 0; }
.device-mobile #modal-body { flex: 1; overflow-y: auto; padding: 16px; }

/* ---------- Modulos movil ---------- */
.device-mobile .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
.device-mobile .form-row, .device-mobile .form-row-3 { grid-template-columns: 1fr; gap: 10px; }
.device-mobile .item-row { grid-template-columns: 1fr 1fr; }
.device-mobile .card { padding: 14px; border-radius: 12px; }
.device-mobile .card-header { flex-wrap: wrap; gap: 8px; }
.device-mobile .card-header h2 { font-size: 16px; }
.device-mobile .search-bar { flex-wrap: wrap; }
.device-mobile .btn { min-height: 40px; }
.device-mobile .login-container { padding: 16px; }
.device-mobile .login-card { padding: 26px; border-radius: 14px; }

/* ---------- Dark mode movil ---------- */
body.dark-mode .mob-topbar { background: var(--gray-800); border-bottom-color: var(--gray-700); }
body.dark-mode .mob-icon-btn { background: var(--gray-700); border-color: var(--gray-600); color: var(--gray-300); }
body.dark-mode .mob-app-name { color: #a5b4fc; }
body.dark-mode .mob-page-title { color: var(--gray-100); }
body.dark-mode .mob-bottomnav { background: var(--gray-800); border-top-color: var(--gray-700); }
body.dark-mode .mob-nav-btn { color: var(--gray-400); }
body.dark-mode .mob-nav-btn:hover, body.dark-mode .mob-nav-btn.active { color: #a5b4fc; }
body.dark-mode .mob-nav-btn.active .mob-nav-icon { background: #312e81; }
body.dark-mode .mob-home-head h2 { color: var(--gray-500); }
body.dark-mode .mob-home-user { color: var(--gray-100); }
body.dark-mode .mob-mod-card { background: var(--gray-800); border-color: var(--gray-700); }
body.dark-mode .mob-mod-icon { background: #312e81; color: #a5b4fc; }
body.dark-mode .mob-mod-label { color: var(--gray-200); }

@media (max-width: 380px) {
  .mob-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Mejoras touch / móvil ---------- */
button, a, input, textarea, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.device-mobile input, .device-mobile textarea, .device-mobile select { font-size: 16px; }
.device-mobile .chat-icon-btn { width: 34px; height: 34px; }
.device-mobile .chat-tool-btn { width: 40px; height: 40px; }
.device-mobile .chat-tool-btn svg { width: 20px; height: 20px; }
.device-mobile .chat-input { font-size: 16px; }

/* ===== Nuevas funciones del chat (WhatsApp-like) ===== */

/* Banner de llamada entrante (siempre visible, aun con chat cerrado) */
.call-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1400;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: linear-gradient(135deg, #15803d, #16a34a);
  color: white; box-shadow: 0 4px 18px rgba(0,0,0,0.35); gap: 12px;
}
.call-banner-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.call-banner-avatar { display: flex; }
.call-banner-avatar .chat-avatar { background: rgba(255,255,255,0.22); }
.call-banner-name { font-size: 14px; font-weight: 700; }
.call-banner-sub { font-size: 12px; opacity: 0.9; }
.call-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
.call-banner-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; color: white;
}
.call-banner-decline { background: var(--danger, #dc2626); }
.call-banner-accept { background: var(--success, #16a34a); }
.call-banner-btn:active { transform: scale(0.92); }

/* Pildora flotante de llamada en curso */
.call-float-pill {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 18px; z-index: 1450;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--gray-900, #111827); color: white; border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4); font-size: 13px;
}
.call-float-info { display: flex; align-items: center; gap: 8px; }
.call-float-actions { display: flex; gap: 6px; }
.call-float-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,0.15); color: white; display: flex;
  align-items: center; justify-content: center;
}
.call-float-btn.active { background: var(--primary, #2563eb); }
.call-float-hangup { background: var(--danger, #dc2626); }
.call-float-hangup:hover { background: #b91c1c; }

/* Busqueda de mensajes */
.chat-search-overlay {
  position: absolute; inset: 0; z-index: 70; background: white;
  display: flex; flex-direction: column;
}
.dark-mode .chat-search-overlay { background: var(--gray-900, #0f172a); }
.chat-search-box { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--gray-200); }
.chat-search-icon { color: var(--gray-400); font-size: 16px; }
.chat-search-box input { flex: 1; border: none; outline: none; font-size: 14px; background: transparent; color: inherit; }
.chat-search-results { flex: 1; overflow-y: auto; padding: 6px 0; }
.chat-search-hint { padding: 18px 16px; color: var(--gray-400); font-size: 12px; text-align: center; }
.chat-search-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--gray-100); }
.chat-search-item:hover { background: var(--gray-50); }
.chat-search-item-room { font-size: 11px; color: var(--primary); font-weight: 700; }
.chat-search-item-text { font-size: 13px; color: var(--gray-800); margin-top: 2px; }
.chat-search-item-time { font-size: 11px; color: var(--gray-400); margin-top: 2px; }

/* Mensajes fijados */
.chat-pinned {
  display: flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: var(--primary-light, #dbeafe); border-bottom: 1px solid var(--gray-200);
  overflow-x: auto; font-size: 12px;
}
.chat-pinned-title { display: flex; align-items: center; gap: 4px; font-weight: 700; color: var(--primary); white-space: nowrap; }
.chat-pinned-title svg { width: 13px; height: 13px; }
.chat-pinned-item {
  display: flex; align-items: center; gap: 4px; background: white; border: 1px solid var(--gray-200);
  border-radius: 999px; padding: 3px 10px; font-size: 11px; cursor: pointer; white-space: nowrap;
  color: var(--gray-700); max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}
.chat-pinned-item svg { width: 11px; height: 11px; flex-shrink: 0; }
.chat-pinned-item:hover { background: var(--gray-50); }
.chat-pinned-tag { display: inline-flex; color: var(--primary); margin-right: 3px; }
.chat-pinned-tag svg { width: 12px; height: 12px; }

/* Menu de sala (más opciones) */
.chat-room-menu {
  position: fixed; z-index: 1300; background: white; border: 1px solid var(--gray-200);
  border-radius: 10px; box-shadow: 0 12px 36px rgba(0,0,0,0.22); min-width: 210px;
  padding: 6px; animation: chatIn 0.15s ease-out;
}
.dark-mode .chat-room-menu { background: var(--gray-800, #1f2937); border-color: var(--gray-700); }
.chat-room-menu-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px;
  border: none; background: none; cursor: pointer; font-size: 13px; text-align: left;
  border-radius: 7px; color: var(--gray-800);
}
.dark-mode .chat-room-menu-btn { color: var(--gray-100); }
.chat-room-menu-btn:hover { background: var(--gray-100); }
.chat-room-menu-btn.danger { color: var(--danger); }
.chat-room-menu-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Menciones */
.chat-mention { color: var(--primary); font-weight: 700; }
.chat-mention-pop {
  position: fixed; z-index: 1350; background: white; border: 1px solid var(--gray-200);
  border-radius: 10px; box-shadow: 0 12px 36px rgba(0,0,0,0.22); overflow: hidden; max-width: 260px;
}
.dark-mode .chat-mention-pop { background: var(--gray-800, #1f2937); border-color: var(--gray-700); }
.chat-mention-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px;
}
.chat-mention-item:hover { background: var(--gray-100); }

/* Entradas de llamada en el chat */
.chat-call-entry {
  display: flex; align-items: center; gap: 10px; padding: 6px 4px; min-width: 220px;
}
.chat-call-entry-icon { font-size: 18px; }
.chat-call-entry-text { flex: 1; font-size: 13px; }
.chat-call-entry-time { font-size: 11px; color: var(--gray-400); }
.chat-call-entry.missed .chat-call-entry-text > div:first-child { color: var(--danger); font-weight: 600; }
.chat-call-redial { flex-shrink: 0; }

/* Historial de llamadas */
.chat-call-history { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.chat-call-row { display: flex; align-items: center; gap: 10px; padding: 9px 8px; border-radius: 8px; }
.chat-call-row:hover { background: var(--gray-50); }
.chat-call-row.missed { background: #fef2f2; }
.dark-mode .chat-call-row.missed { background: rgba(220,38,38,0.12); }
.chat-call-row-info { flex: 1; min-width: 0; }
.chat-call-row-name { font-size: 13px; font-weight: 600; }
.chat-call-row-sub { font-size: 11px; color: var(--gray-400); }

/* Reenviado y velocidad de voz */
.chat-forwarded-tag { font-size: 10px; color: var(--gray-400); font-style: italic; margin-bottom: 2px; }
.chat-voice-speed {
  border: none; background: none; color: var(--gray-400); font-size: 10px; cursor: pointer;
  padding: 2px 4px; border-radius: 4px; align-self: center;
}
.chat-voice-speed:hover { color: var(--primary); }

/* Salas archivadas */
.chat-rooms-archived-toggle {
  padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--gray-500);
  cursor: pointer; border-bottom: 1px solid var(--gray-200); text-align: center;
}
.chat-rooms-archived-toggle:hover { background: var(--gray-100); color: var(--primary); }
.chat-rooms-list-inner { flex: 1; overflow-y: auto; min-height: 0; }
.chat-room-item.archived { opacity: 0.65; }
.chat-room-muted { margin-left: 4px; font-size: 11px; }

/* Destello al saltar a un mensaje de la busqueda */
.chat-msg-flash { animation: chatFlash 2.4s ease; }
@keyframes chatFlash { 0% { background: rgba(37, 99, 235, 0.35); } 100% { background: transparent; } }

.device-mobile .call-banner-name { font-size: 13px; }
.device-mobile .call-float-pill { bottom: 76px; }

/* ============================================
   PROGRESO DE CARGA GLOBAL + SCROLLBARS TEMATICOS
   ============================================ */
#global-progress {
  position: fixed; top: 0; left: 0; width: 100%; height: 3px;
  z-index: 9999; pointer-events: none; opacity: 0;
  transition: opacity 0.25s ease;
}
#global-progress.active { opacity: 1; }
#global-progress > div {
  height: 100%; width: 40%; border-radius: 0 2px 2px 0;
  background: linear-gradient(90deg, var(--primary), var(--accent), #ec4899);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.55);
  animation: globalProgressSlide 1.1s ease-in-out infinite;
}
@keyframes globalProgressSlide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

* { scrollbar-width: thin; scrollbar-color: rgba(99, 102, 241, 0.32) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background-color: rgba(79, 70, 229, 0.55); }
::-webkit-scrollbar-corner { background: transparent; }
body.dark-mode::-webkit-scrollbar-thumb { background: rgba(165, 180, 252, 0.35); background-clip: content-box; border: 2px solid transparent; }
body.dark-mode::-webkit-scrollbar-thumb:hover { background-color: rgba(199, 210, 254, 0.55); }

/* ============ Forum Abogados ============ */
.forum-topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.forum-topic-card { margin: 0; cursor: pointer; display: flex; flex-direction: column; gap: 8px; }
.forum-topic-title { font-weight: 600; font-size: 15px; color: var(--gray-800); word-break: break-word; }
.forum-topic-desc { font-size: 13px; color: var(--gray-500); white-space: pre-wrap; word-break: break-word; }
.forum-meta { font-size: 12px; color: var(--gray-500); }
.forum-meta strong { color: var(--gray-700); }
.forum-topic-foot { display: flex; gap: 10px; font-size: 12px; color: var(--gray-500); margin-top: auto; }
.forum-empty { text-align: center; padding: 34px 12px; border: 1px dashed var(--gray-300); border-radius: 12px; color: var(--gray-500); }
.forum-file-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--gray-200); border-radius: 10px; margin-bottom: 8px; background: white; }
.forum-file-icon { font-size: 22px; }
.forum-file-body { flex: 1; min-width: 0; }
.forum-file-name { font-weight: 600; font-size: 13px; word-break: break-all; color: var(--primary-dark); text-decoration: none; }
.forum-file-name:hover { text-decoration: underline; }
.forum-file-sub { font-size: 11px; color: var(--gray-500); margin-top: 2px; }
.forum-msg-box { max-height: 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 2px; }
.forum-msg { align-self: flex-start; max-width: 88%; display: flex; flex-direction: column; gap: 2px; }
.forum-msg.mine { align-self: flex-end; }
.forum-msg-head { font-size: 11px; color: var(--gray-500); padding: 0 2px; text-align: left; }
.forum-msg.mine .forum-msg-head { text-align: right; }
.forum-bubble { background: var(--gray-100); color: var(--gray-800); padding: 8px 12px; border-radius: 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.forum-msg.mine .forum-bubble { background: var(--primary); color: #fff; }
.forum-msg-del { align-self: flex-start; }
.forum-msg.mine .forum-msg-del { align-self: flex-end; }
.forum-chat-input { flex: 1; padding: 10px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 14px; outline: none; background: white; color: var(--gray-800); }
.forum-chat-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

body.dark-mode .forum-topic-title { color: var(--gray-100); }
body.dark-mode .forum-topic-desc { color: var(--gray-400); }
body.dark-mode .forum-meta { color: var(--gray-400); }
body.dark-mode .forum-meta strong { color: var(--gray-200); }
body.dark-mode .forum-topic-foot { color: var(--gray-400); }
body.dark-mode .forum-empty { border-color: var(--gray-600); color: var(--gray-400); }
body.dark-mode .forum-file-row { background: var(--gray-800); border-color: var(--gray-700); }
body.dark-mode .forum-file-name { color: var(--primary-light); }
body.dark-mode .forum-file-sub { color: var(--gray-400); }
body.dark-mode .forum-msg-head { color: var(--gray-400); }
body.dark-mode .forum-bubble { background: var(--gray-700); color: var(--gray-100); }
body.dark-mode .forum-msg.mine .forum-bubble { background: var(--primary); color: #fff; }
body.dark-mode .forum-chat-input { background: var(--gray-700); border-color: var(--gray-600); color: #fff; }

/* ============================ CIERRE ECONÓMICO ============================ */
.acc-outer { padding-bottom: 20px; }
.acc-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.acc-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.acc-tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid var(--gray-200); padding: 4px 4px 0; margin-bottom: 16px; }
.acc-tab { background: transparent; border: none; border-bottom: 3px solid transparent; padding: 9px 13px; font-size: 13px; font-weight: 600; color: var(--gray-500); cursor: pointer; border-radius: 6px 6px 0 0; white-space: nowrap; transition: all .15s; }
.acc-tab:hover { background: var(--gray-50); color: var(--gray-700); }
.acc-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--primary-light); }
.acc-content { min-height: 200px; }
.acc-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; margin-bottom: 14px; }
.acc-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.acc-note { background: var(--primary-light); border-left: 4px solid var(--primary); padding: 10px 12px; border-radius: 6px; font-size: 13.5px; color: var(--gray-700); margin-bottom: 14px; }
.acc-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--gray-200); color: var(--gray-600); font-size: 11px; font-weight: 600; }
.acc-acc { max-width: 320px; padding: 6px 8px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 13px; background: #fff; color: var(--gray-700); }
#en-lines td input { width: 100%; padding: 5px 6px; border: 1px solid var(--gray-300); border-radius: 5px; font-size: 13px; }
#en-lines td input.en-debit, #en-lines td input.en-credit { text-align: right; }
.inv-real { text-align: right; padding: 4px 6px; border: 1px solid var(--gray-300); border-radius: 5px; font-size: 13px; }
@media (max-width: 800px) {
  .acc-2col { grid-template-columns: 1fr; }
  .closure-stats { grid-template-columns: repeat(2, 1fr); }
}
@media print {
  .acc-toolbar, .acc-tabs { display: none !important; }
}
body.dark-mode .acc-bar { background: var(--gray-800); border-color: var(--gray-700); }
body.dark-mode .acc-note { background: #1e293b; color: var(--gray-200); }
body.dark-mode .acc-tab.active { background: var(--gray-800); }
body.dark-mode .acc-acc, body.dark-mode #en-lines td input, body.dark-mode .inv-real { background: var(--gray-800); color: var(--gray-100); border-color: var(--gray-600); }

/* ============================================================
   REFINAMIENTO MODERNO — edicion de escritorio y web
   ============================================================ */

/* Seleccion de texto con el color de marca */
::selection { background: rgba(99, 102, 241, 0.22); }

/* Transicion uniforme en todos los controles de formulario */
input, select, textarea { transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease; }

/* Modal con vidrio esmerilado mas marcado */
.modal { backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* Cabeceras de tabla mas definidas (corte preciso) */
th { border-bottom: 2px solid var(--gray-200); }
body.dark-mode th { border-bottom-color: var(--gray-600); }

/* Tarjetas de estadisticas: filete degradado superior */
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0.9; pointer-events: none;
}

/* Foco visible y consistente en todo el sistema */
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}

/* Respeto por la preferencia de movimiento reducido del sistema */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   CROMO DE ESCRITORIO (app Electron) — solo con .desktop-chrome
   Barra de ventana propia + login con marca Olazalabs.
   En la version web todo esto permanece oculto e inerte.
   ============================================================ */

#desktop-titlebar {
  position: fixed; top: 0; left: 0; right: 0; height: 40px; z-index: 1200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 0 0 14px;
  background: linear-gradient(90deg, #0a1220 0%, #0e1a30 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  -webkit-app-region: drag; user-select: none;
}
/* En la version web el atributo hidden la mantiene fuera de la vista */
#desktop-titlebar[hidden] { display: none; }
.dtb-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.dtb-logo { height: 22px; width: auto; display: block; }
.dtb-name { color: #e2e8f0; font-size: 12.5px; font-weight: 700; letter-spacing: 0.2px; white-space: nowrap; }
.dtb-by { color: #64748b; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap; }
.dtb-controls { display: flex; height: 100%; -webkit-app-region: no-drag; }
.dtb-btn {
  width: 46px; height: 100%; border: none; background: transparent; cursor: pointer;
  color: #94a3b8; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.dtb-btn:hover { background: rgba(255, 255, 255, 0.08); color: #e2e8f0; }
.dtb-btn:active { background: rgba(255, 255, 255, 0.14); }
.dtb-btn svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.dtb-btn-qr:hover { background: rgba(79, 70, 229, 0.28); color: #c7d2fe; }
.dtb-btn-qr svg { width: 15px; height: 15px; stroke-width: 1.7; }
.dtb-btn-close:hover { background: #e11d48; color: #fff; }
.dtb-btn .dtb-icon-restore { display: none; }
.dtb-btn.dtb-restore .dtb-icon-max { display: none; }
.dtb-btn.dtb-restore .dtb-icon-restore { display: block; }

/* Deja sitio bajo la barra para todo el cromo existente */
.desktop-chrome .sidebar { top: 40px; height: calc(100vh - 40px); }
.desktop-chrome #main-app { margin-top: 40px; height: calc(100vh - 40px); }
.desktop-chrome .login-container { padding-top: 40px; }
.desktop-chrome #global-progress { top: 40px; }

/* ---------- Login de escritorio: sin tarjeta, todo flota sobre el fondo ---------- */
.desktop-chrome .login-container {
  background: linear-gradient(135deg, #071018 0%, #0b2545 58%, #0e7490 140%);
}
.desktop-chrome .login-container::before {
  width: 560px; height: 560px; top: -140px; right: -130px; border-radius: 0; filter: none; opacity: 0.10;
  background: transparent url('../brand/isotipo.svg') center / contain no-repeat;
}
.desktop-chrome .login-container::after {
  width: 420px; height: 420px; bottom: -150px; left: -90px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.35), transparent 70%);
}
/* La tarjeta desaparece: el contenido se apoya directamente en el fondo */
.desktop-chrome .login-card {
  background: transparent; border: none; box-shadow: none; border-radius: 0;
  padding: 24px 4px; max-width: 400px; position: relative;
}
.desktop-chrome .desktop-brand {
  display: block; width: 76px; height: 76px; margin: 0 auto 18px;
  filter: drop-shadow(0 12px 28px rgba(6, 182, 212, 0.35));
}
.desktop-chrome .login-brand-logo { filter: drop-shadow(0 12px 28px rgba(6, 182, 212, 0.35)); }
.desktop-chrome .login-card h1 {
  font-size: 24px; font-weight: 800; letter-spacing: -0.4px; margin-bottom: 6px; color: #f8fafc;
}
.desktop-chrome .login-sub { color: #94a3b8; margin-bottom: 20px; }
.desktop-chrome .login-subheading { color: #e2e8f0; }
/* Campos flotantes en cristal */
.desktop-chrome .login-card input {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f1f5f9;
}
.desktop-chrome .login-card input::placeholder { color: #8ba0b8; }
.desktop-chrome .login-card input:focus {
  border-color: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.22);
  background: rgba(255, 255, 255, 0.1);
}
.desktop-chrome .login-card input[readonly] {
  background: rgba(255, 255, 255, 0.04); color: #a9bcd2; border-style: dashed;
}
.desktop-chrome .login-card input[type="checkbox"] {
  width: 16px; height: 16px; padding: 0; border: none; background: none;
  box-shadow: none; accent-color: #22d3ee; flex: none;
}
.desktop-chrome .login-card input[type="checkbox"]:focus { box-shadow: none; }
.desktop-chrome .login-card label { color: #94a3b8; }
.desktop-chrome .login-card .hint { color: #7f93ad; }
.desktop-chrome .login-link { color: #38bdf8; }
.desktop-chrome .login-divider { border-top-color: rgba(255, 255, 255, 0.12); }
/* Pestañas */
.desktop-chrome #login-tabs { border-bottom-color: rgba(255, 255, 255, 0.14); }
.desktop-chrome #login-tabs .tab-btn { color: #8ea3bd; }
.desktop-chrome #login-tabs .tab-btn:hover { color: #e2e8f0; }
.desktop-chrome #login-tabs .tab-btn.active { color: #38bdf8; border-bottom-color: #22d3ee; }
/* Botones con la paleta de la marca */
.desktop-chrome .login-card .btn-primary {
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  box-shadow: 0 10px 24px rgba(6, 182, 212, 0.28);
}
.desktop-chrome .login-card .btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #0891b2);
  box-shadow: 0 14px 30px rgba(6, 182, 212, 0.38);
}
.desktop-chrome .login-card .btn-outline {
  background: rgba(255, 255, 255, 0.06); color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.desktop-chrome .login-card .btn-outline:hover {
  background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.3); color: #f1f5f9;
}
.desktop-chrome .login-card .btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.25);
}
/* Mensajes sobre fondo oscuro */
.desktop-chrome .login-card .error-text { color: #fca5a5; }
.desktop-chrome #activation-notice { color: #fcd34d; }
.desktop-chrome .login-card .license-info { color: #6ee7b7; }
.desktop-chrome #device-toggle-link { display: none; }
.desktop-chrome .login-byline {
  color: #8ba0b8; border-top-color: rgba(255, 255, 255, 0.12);
}
.desktop-chrome .login-byline b { color: #38bdf8; }
.desktop-chrome .login-byline:hover { color: #e2e8f0; }
