/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --bg-card: #1e2a45;
  --bg-hover: #253558;
  --accent: #0068ff;
  --accent-hover: #0052cc;
  --accent-light: #5c9dff; /* ≥4.5:1 trên thẻ (WCAG AA) */
  --success: #00c851;
  --warning: #ffbb33;
  --danger: #ff6b6b;
  --info: #33b5e5;
  --text-primary: #e8eaf6;
  --text-secondary: #b3b8d4;
  --text-muted: #949cc0; /* trước #5c6480 chỉ 2.4:1 trên thẻ */
  --border: #2a3560;
  --border-light: #3a4570;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --sidebar-width: 240px;
  --titlebar-height: 38px;
  --font: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

a { color: var(--accent-light); }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ===== TITLE BAR ===== */
.title-bar {
  height: var(--titlebar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  -webkit-app-region: drag;
  user-select: none;
  flex-shrink: 0;
  z-index: 100;
}

.title-bar-drag {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.title-bar-version {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 20px;
}

.title-bar-controls {
  display: flex;
  gap: 2px;
  -webkit-app-region: no-drag;
}

.tb-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: var(--transition);
}

.tb-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tb-btn.tb-close:hover { background: var(--danger); color: white; }

/* ===== MAIN LAYOUT ===== */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-header {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info {
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-plan {
  font-size: 11px;
  margin-top: 2px;
}

.user-plan.trial { color: var(--warning); }
.user-plan.pro { color: var(--success); }
.user-plan.premium { color: var(--accent); }

.nav-group {
  padding: 8px 0;
}

.nav-label {
  padding: 6px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  cursor: pointer;
  border-radius: 0;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-left-color: var(--border-light);
}

.nav-item.active {
  background: rgba(0, 104, 255, 0.15);
  color: var(--accent-light);
  border-left-color: var(--accent);
}

.nav-icon {
  font-size: 15px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-text {
  font-size: 13px;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--danger);
  color: white;
  flex-shrink: 0;
}

.nav-badge.log-badge {
  background: var(--warning);
  color: #000;
}

/* ===== CONTENT ===== */
.content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
  min-width: 0;
}

.content::-webkit-scrollbar { width: 6px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.content::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== PAGE LAYOUT ===== */
.page {
  padding: 20px;
  min-height: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.yellow::before { background: var(--warning); }
.stat-card.red::before { background: var(--danger); }

.stat-icon {
  font-size: 22px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
}

.stat-change {
  font-size: 11px;
  color: var(--success);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover { background: #00a844; }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover { background: #cc0000; }

.btn-warning {
  background: var(--warning);
  color: #000;
}

.btn-warning:hover { background: #ff9900; }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 15px;
}

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

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 14px;
}

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

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 104, 255, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ea3c0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ===== TABLE ===== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

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

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-online { background: rgba(0, 200, 81, 0.15); color: var(--success); }
.badge-offline { background: rgba(92, 100, 128, 0.15); color: var(--text-muted); }
.badge-running { background: rgba(0, 104, 255, 0.15); color: var(--accent-light); }
.badge-done { background: rgba(0, 200, 81, 0.15); color: var(--success); }
.badge-error { background: rgba(255, 68, 68, 0.15); color: var(--danger); }
.badge-pending { background: rgba(255, 187, 51, 0.15); color: var(--warning); }

/* ===== PROGRESS ===== */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 10px 18px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: var(--transition);
}

.modal-close:hover { color: var(--danger); background: rgba(255,68,68,0.1); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

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

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.toast {
  min-width: 280px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  border-left: 3px solid;
}

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-success { background: var(--bg-card); border-color: var(--success); color: var(--text-primary); }
.toast-error { background: var(--bg-card); border-color: var(--danger); color: var(--text-primary); }
.toast-info { background: var(--bg-card); border-color: var(--info); color: var(--text-primary); }
.toast-warning { background: var(--bg-card); border-color: var(--warning); color: var(--text-primary); }

.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: 13px; }
.toast-message { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  max-width: 300px;
}

/* ===== LOADING ===== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: inherit;
}

/* ===== WEBVIEW ===== */
.webview-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.webview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.webview-url {
  flex: 1;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
}

webview {
  flex: 1;
  width: 100%;
  min-height: 0;
}

/* ===== SPINTAX ===== */
.spintax-preview {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--info);
  margin-top: 8px;
  min-height: 40px;
}

/* ===== LOG ENTRIES ===== */
.log-entry {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-family: 'Consolas', monospace;
  transition: var(--transition);
}

.log-entry:hover { background: var(--bg-hover); }
.log-entry.success .log-level { color: var(--success); }
.log-entry.error .log-level { color: var(--danger); }
.log-entry.info .log-level { color: var(--info); }
.log-entry.warning .log-level { color: var(--warning); }

.log-time { color: var(--text-muted); flex-shrink: 0; width: 80px; }
.log-level { width: 60px; flex-shrink: 0; font-weight: 600; }
.log-account { color: var(--accent-light); flex-shrink: 0; width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-message { flex: 1; color: var(--text-secondary); }

/* ===== ACCOUNT CARDS ===== */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition);
  position: relative;
}

.account-card:hover {
  border-color: var(--accent);
}

.account-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.account-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

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

.account-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-phone {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.account-stats {
  display: flex;
  gap: 14px;
}

.account-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-stat-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.account-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ===== TASK PROGRESS ===== */
.task-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.task-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.task-counter {
  font-size: 12px;
  color: var(--text-secondary);
}

.task-counter strong {
  color: var(--text-primary);
  font-size: 14px;
}

/* ===== TOOLTIPS ===== */
[title] {
  position: relative;
}

/* ===== ANIMATIONS ===== */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== SCROLLBARS ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ===== DIVIDER ===== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ===== GRID HELPERS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-secondary); font-size: 12px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-info { color: var(--info); }
.text-warning { color: var(--warning); }

/* ===== SEARCH BAR ===== */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.search-bar input {
  padding-left: 34px;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}

/* ===== TOGGLE SWITCH ===== */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border-light);
  border-radius: 22px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ===== INFO ALERT ===== */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-left: 3px solid;
  margin-bottom: 14px;
}

.alert-info { background: rgba(51,181,229,0.1); border-color: var(--info); color: var(--info); }
.alert-success { background: rgba(0,200,81,0.1); border-color: var(--success); color: var(--success); }
.alert-warning { background: rgba(255,187,51,0.1); border-color: var(--warning); color: var(--warning); }
.alert-danger { background: rgba(255,68,68,0.1); border-color: var(--danger); color: var(--danger); }

/* ===== UI KIT (thành phần dùng chung) ===== */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-label { font-size: 11px; color: var(--text-muted); }
.chip { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); border-radius: 14px; padding: 2px 10px; font-size: 11px; cursor: pointer; transition: var(--transition); font-family: inherit; }
.chip:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.chip-ai { background: linear-gradient(90deg, #6a3de8, #0068ff); color: #fff; border: none; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; background: var(--bg-tertiary); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-x { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: none; background: rgba(0,0,0,.7); color: #fff; font-size: 10px; cursor: pointer; }
.thumb-name { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 9px; padding: 1px 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.picker-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.picker-count { font-size: 12px; color: var(--text-secondary); margin-left: auto; }
.picker-table { max-height: 380px; overflow: auto; }
.picker-pages { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 8px; font-size: 12px; color: var(--text-secondary); }
.row-sel td { background: rgba(0, 104, 255, 0.12); }
.avt { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; vertical-align: middle; margin-right: 6px; }
.avt-ph { display: inline-flex; align-items: center; justify-content: center; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; }
.ai-variant { background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; font-size: 13px; }
.jp-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.jp-tab { background: var(--bg-tertiary); border: 1px solid var(--border); color: var(--text-secondary); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.jp-tab.active { border-color: var(--accent); color: var(--text-primary); background: var(--bg-hover); }
.jp-tab small { color: var(--text-muted); }
.jp-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.jp-table { max-height: 340px; overflow: auto; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); margin-right: 6px; }
.dot.live { background: var(--success); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.zalo-tab { display: flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; font-size: 13px; color: var(--text-secondary); transition: .2s; }
.zalo-tab.active { background: var(--bg-hover); color: var(--accent-light); }
.zdot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); display: inline-block; }
.zunread { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; line-height: 16px; }
.bars { display: flex; gap: 6px; align-items: flex-end; height: 130px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; }
.bar-ok { background: var(--success); border-radius: 3px 3px 0 0; min-height: 0; }
.bar-fail { background: var(--danger); }
.bar-label { font-size: 10px; color: var(--text-muted); margin-top: 3px; }
.settings-tab { display: none; }
code { background: rgba(0,0,0,.25); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ===== HỘP THƯ CHUNG ===== */
.ib { display: flex; height: 100%; min-height: 0; }
.ib-rail { width: 68px; flex-shrink: 0; background: var(--bg-secondary); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 0; overflow-y: auto; }
.ib-acc { position: relative; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; color: #fff; cursor: pointer; opacity: .55; transition: var(--transition); flex-shrink: 0; }
.ib-acc:hover { opacity: .85; }
.ib-acc.active { opacity: 1; box-shadow: 0 0 0 2px var(--bg-secondary), 0 0 0 4px var(--accent-light); }
.ib-acc .ib-badge { position: absolute; top: -5px; right: -6px; }
.ib-acc .ib-dot { position: absolute; bottom: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--bg-secondary); background: var(--text-muted); }
.ib-acc .ib-dot.on { background: var(--success); }
.ib-acc .ib-dot.warn { background: var(--warning); }
.ib-acc .ib-kind { position: absolute; bottom: -4px; left: -4px; font-size: 11px; }
.ib-sep { width: 32px; height: 1px; background: var(--border); flex-shrink: 0; }
.ib-badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; line-height: 17px; font-weight: 700; min-width: 17px; text-align: center; }
.ib-list { width: 330px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--bg-primary); }
.ib-list-head { padding: 14px 14px 10px; border-bottom: 1px solid var(--border); }
.ib-list-title { font-weight: 700; font-size: 15px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.ib-list-title .ib-sub { font-weight: 400; font-size: 12px; color: var(--text-muted); }
.ib-threads { flex: 1; overflow-y: auto; }
.ib-th { display: flex; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.03); }
.ib-th:hover { background: var(--bg-hover); }
.ib-th.active { background: var(--bg-card); }
.ib-av { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; flex-shrink: 0; font-size: 15px; }
.ib-th-main { flex: 1; min-width: 0; }
.ib-th-top { display: flex; align-items: center; gap: 6px; }
.ib-th-title { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-th.unread .ib-th-title { color: var(--text-primary); }
.ib-th-time { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }
.ib-th-bot { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.ib-th-last { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-th.unread .ib-th-last { color: var(--text-primary); font-weight: 600; }
.ib-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-secondary); white-space: nowrap; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.ib-tag i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ib-chat { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.ib-chat-head { padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.ib-chat-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.ib-msg { max-width: 70%; align-self: flex-start; }
.ib-msg.out { align-self: flex-end; }
.ib-bubble { background: var(--bg-card); padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.ib-msg.out .ib-bubble { background: var(--accent); color: #fff; }
.ib-meta { font-size: 10.5px; color: var(--text-muted); margin: 2px 4px 0; }
.ib-msg.out .ib-meta { text-align: right; }
.ib-from { font-size: 11px; color: var(--accent-light); margin: 0 4px 2px; font-weight: 600; }
.ib-compose { border-top: 1px solid var(--border); padding: 10px 14px; display: flex; gap: 10px; align-items: flex-end; }
.ib-compose textarea { flex: 1; resize: none; min-height: 42px; max-height: 140px; }
.ib-warn { margin: 8px 12px 0; padding: 8px 10px; border-radius: var(--radius-sm); background: rgba(255,187,51,.12); color: var(--warning); font-size: 12px; display: flex; align-items: center; gap: 8px; }
.ib-empty { margin: auto; text-align: center; color: var(--text-muted); padding: 24px; }
/* Hộp thư chung — ảnh đại diện (ảnh lỗi thì tự bỏ, lộ chữ cái đầu phía dưới) */
.ib-av { position: relative; overflow: hidden; }
.ib-av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ib-av.sm { width: 28px; height: 28px; font-size: 12px; }
.ib-av.ph { visibility: hidden; }
.ib-acc img { position: absolute; top: 3px; left: 3px; width: calc(100% - 6px); height: calc(100% - 6px); object-fit: cover; border-radius: 9px; }
.ib-acc .ib-dot, .ib-acc .ib-kind, .ib-acc > span { z-index: 2; }
.ib-row { display: flex; gap: 8px; align-items: flex-end; max-width: 75%; align-self: flex-start; }
.ib-row .ib-msg { max-width: none; min-width: 0; }
/* Hộp thư chung — đính kèm */
.ib-bubble.media { padding: 4px; background: var(--bg-card); }
.ib-msg.out .ib-bubble.media { background: var(--bg-card); color: var(--text-primary); }
.ib-photo { display: block; max-width: 320px; max-height: 320px; border-radius: 9px; cursor: zoom-in; }
.ib-caption { padding: 6px 8px 4px; white-space: pre-wrap; word-break: break-word; }
.ib-video { position: relative; min-width: 200px; min-height: 120px; border-radius: 9px; overflow: hidden; cursor: pointer; background: #000; }
.ib-video img { display: block; max-width: 320px; max-height: 260px; }
.ib-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 34px; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.7); }
.ib-file { padding: 8px 10px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.ib-file:hover, .ib-linkcard:hover { background: var(--bg-hover); border-radius: 9px; }
.ib-file-name { color: var(--accent-light); text-decoration: underline; word-break: break-all; }
.ib-file-size { color: var(--text-muted); font-size: 11px; }
.ib-linkcard { cursor: pointer; max-width: 320px; }
.ib-linkcard img { display: block; max-width: 100%; max-height: 180px; border-radius: 9px; }
.ib-link-title { padding: 6px 8px; color: var(--accent-light); word-break: break-word; }
.ib-lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; }
.ib-lightbox img { max-width: 92%; max-height: 82%; border-radius: 6px; box-shadow: var(--shadow); }
.ib-lb-bar { display: flex; gap: 8px; }

/* ===== Bàn phím: viền focus cho mọi phần tử bấm được (quy tắc ui-ux-pro-max: không bỏ focus ring) ===== */
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.nav-item:focus-visible { outline-offset: -2px; }

/* ===== Menu: nhóm gập được (app.js setupNavGroups) — nhóm gập vẫn hiện mục đang mở ===== */
.nav-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; user-select: none; }
.nav-label:hover { color: var(--text-secondary); }
.nav-label::after { content: '▾'; font-size: 11px; transition: transform var(--transition); }
.nav-group.collapsed .nav-label::after { transform: rotate(-90deg); }
.nav-group.collapsed .nav-item:not(.active) { display: none; }

/* ===== Bản web (server/web/boot.js gắn lớp is-web vào <html>): ẩn phần chỉ có ở app desktop ===== */
html.is-web .title-bar-controls,
html.is-web [data-desktop-only] { display: none !important; }
html.is-web #stTabs .tab:nth-child(4) { display: none; } /* Cài đặt → Cập nhật */
