:root {
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.25);
  --primary-subtle: rgba(139, 92, 246, 0.1);
  --primary-light: rgba(139, 92, 246, 0.15);

  --bg-deep: #09090b;
  --bg: #0f0f12;
  --bg-card: #18181b;
  --bg-elevated: #1e1e23;
  --bg-hover: #27272a;
  --bg-active: #2e2e33;

  --text: #fafafa;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --text-dim: #52525b;

  --border: #27272a;
  --border-light: #1e1e23;
  --border-focus: #8b5cf6;

  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --success-border: rgba(34, 197, 94, 0.25);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.25);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.25);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.12);
  --info-border: rgba(59, 130, 246, 0.25);

  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

/* ═══════════════ SIDEBAR ═══════════════ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-top {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--border-light);
}
.logo {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 50%, #c4b5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
}
.nav-separator {
  height: 1px;
  background: var(--border-light);
  margin: 8px 6px;
}
.nav-link {
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.5; }
.nav-link:hover { background: var(--bg-hover); color: var(--text-secondary); }
.nav-link:hover svg { opacity: 0.9; }
.nav-link.active {
  background: var(--primary-subtle);
  color: var(--primary);
}
.nav-link.active svg { opacity: 1; }

/* Sidebar bottom: stale badge + user */
.sidebar-bottom {
  padding: 12px 10px 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stale-tickets-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #92400e;
  font-weight: 600;
  font-size: 12px;
  width: 100%;
  justify-content: center;
}
.stale-tickets-btn.stale-critical {
  background: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-presence-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition);
  min-width: 0;
}
.sidebar-presence-btn:hover { background: var(--bg-hover); }
.sidebar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.sidebar-user-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}
.sidebar-action-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-action-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }

.role-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.role-admin {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(245, 158, 11, 0.1));
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}
.role-staff {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ═══════════════ CONTAINER ═══════════════ */
.container { max-width: 1360px; margin-left: 240px; margin-right: 0; padding: 32px 28px; }
.page-header {
  margin-bottom: 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.page-header h2 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.8px;
}

/* ═══════════════ CARDS ═══════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  transition: all var(--transition);
}
.card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 18px;
  color: var(--text);
}

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all var(--transition);
}
.stat-card:hover {
  border-color: var(--border-focus);
  box-shadow: 0 0 20px var(--primary-glow);
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.stat-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}
.stat-card.stat-open .stat-value { color: var(--info); }
.stat-card.stat-progress .stat-value { color: var(--warning); }
.stat-card.stat-resolved .stat-value { color: var(--success); }
.stat-card.stat-total .stat-value { color: var(--primary); }

/* ═══════════════ BUTTONS ═══════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  font-family: inherit;
  line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--text-dim);
  color: var(--text);
}
.btn-danger-outline {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger-border);
}
.btn-danger-outline:hover {
  background: var(--danger-bg);
}
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  opacity: 0.85;
}
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }

/* ═══════════════ FORMS ═══════════════ */
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
input[type="text"], input[type="date"], input[type="email"],
input[type="password"], input[type="number"],
select, textarea {
  width: 100%;
  padding: 11px 16px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-elevated);
  transition: all var(--transition);
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
  background: var(--bg-card);
}
input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
select option {
  background: var(--bg-card);
  color: var(--text);
}
textarea { resize: vertical; min-height: 100px; }
.inline-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 150px; }

/* ═══════════════ FILTERS ═══════════════ */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
}
.filters select, .filters input { width: auto; min-width: 150px; }
.filters label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* ═══════════════ TABLE ═══════════════ */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table th {
  background: var(--bg-elevated);
  padding: 14px 18px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-light);
  font-size: 14px;
  color: var(--text-secondary);
}
.table tbody tr:last-child td { border-bottom: none; }
.clickable-row {
  cursor: pointer;
  transition: all var(--transition);
}
.clickable-row:hover {
  background: var(--bg-hover);
}
.clickable-row:active {
  background: var(--bg-active);
}
.td-title {
  font-weight: 600;
  color: var(--text);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.td-id {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ═══════════════ STATUS BADGES ═══════════════ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-em_aberto {
  background: var(--info-bg);
  color: #60a5fa;
  border: 1px solid var(--info-border);
}
.status-em_aberto::before { background: #3b82f6; box-shadow: 0 0 6px rgba(59,130,246,0.5); }
.status-em_andamento {
  background: var(--warning-bg);
  color: #fbbf24;
  border: 1px solid var(--warning-border);
}
.status-em_andamento::before { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.5); }
.status-resolvido {
  background: var(--success-bg);
  color: #4ade80;
  border: 1px solid var(--success-border);
}
.status-resolvido::before { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.status-fechado {
  background: rgba(113, 113, 122, 0.1);
  color: var(--text-muted);
  border: 1px solid rgba(113, 113, 122, 0.2);
}
.status-fechado::before { background: #71717a; }
.status-pendente {
  background: rgba(202, 138, 4, 0.12);
  color: #facc15;
  border: 1px solid rgba(202, 138, 4, 0.35);
}
.status-pendente::before { background: #ca8a04; box-shadow: 0 0 6px rgba(202,138,4,0.5); }
.status-reaberto {
  background: rgba(124, 58, 237, 0.12);
  color: #a78bfa;
  border: 1px solid rgba(124, 58, 237, 0.35);
}
.status-reaberto::before { background: #7c3aed; box-shadow: 0 0 6px rgba(124,58,237,0.5); }

/* Generic badge styles for AI attendances */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: rgba(34,197,94,0.12); color: #16a34a; border: 1px solid rgba(34,197,94,0.25); }
.badge-warning { background: rgba(245,158,11,0.12); color: #d97706; border: 1px solid rgba(245,158,11,0.25); }
.badge-info { background: rgba(99,102,241,0.12); color: #6366f1; border: 1px solid rgba(99,102,241,0.25); }
.badge-default { background: rgba(113,113,122,0.12); color: #71717a; border: 1px solid rgba(113,113,122,0.25); }

.tipo-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.tipo-suporte {
  background: rgba(139, 92, 246, 0.12);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.25);
}
.tipo-erro {
  background: var(--danger-bg);
  color: #f87171;
  border: 1px solid var(--danger-border);
}

/* ═══════════════ LOGIN ═══════════════ */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
}
.login-container::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at 30% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 70% 80%, rgba(59, 130, 246, 0.06) 0%, transparent 50%);
  animation: login-glow 15s ease-in-out infinite alternate;
}
@keyframes login-glow {
  0% { transform: translate(0, 0); }
  100% { transform: translate(-5%, -3%); }
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-header { text-align: center; margin-bottom: 40px; }
.login-logo {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 4px 16px var(--primary-glow);
}
.login-logo svg { width: 28px; height: 28px; }
.login-header h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.login-header p {
  color: var(--text-muted);
  font-size: 15px;
}

/* ═══════════════ TICKET DETAIL ═══════════════ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
  transition: all var(--transition);
  padding: 6px 12px;
  border-radius: 8px;
  margin-left: -12px;
}
.back-link:hover {
  color: var(--primary);
  background: var(--primary-subtle);
}
.back-link svg { width: 16px; height: 16px; }
.ticket-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 24px;
}
.ticket-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.ticket-header-top h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}
.ticket-meta-badges { display: flex; gap: 8px; }
.ticket-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
  font-size: 14px;
}
.meta-item {
  color: var(--text-muted);
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.meta-item strong { color: var(--text-secondary); font-weight: 600; }
.ticket-desc {
  font-size: 14px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}
.ticket-desc strong { color: var(--text-secondary); }
.ticket-desc p {
  margin-top: 8px;
  white-space: pre-wrap;
  color: var(--text-secondary);
  line-height: 1.7;
}

.status-changer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 14px;
}
.status-changer select { width: auto; min-width: 160px; }
.status-changer label { font-weight: 600; color: var(--text-secondary); font-size: 13px; }

/* ═══════════════ CHAT ═══════════════ */
.chat-section { margin-bottom: 24px; }
.chat-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-section h3 svg { width: 18px; height: 18px; color: var(--text-muted); }
.chat-timeline {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-height: 540px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.chat-timeline::-webkit-scrollbar { width: 4px; }
.chat-timeline::-webkit-scrollbar-track { background: transparent; }
.chat-timeline::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chat-msg {
  max-width: 75%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  position: relative;
}
.msg-client {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-staff {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.15), rgba(99, 102, 241, 0.1));
  border: 1px solid rgba(139, 92, 246, 0.25);
  border-bottom-right-radius: 4px;
}
.msg-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}
.msg-sender { font-weight: 700; font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; }
.msg-staff .msg-sender { color: #a78bfa; }
.msg-time { font-size: 11px; color: var(--text-dim); font-weight: 500; }
.msg-body { white-space: pre-wrap; word-break: break-word; color: var(--text-secondary); }
.msg-staff .msg-body { color: var(--text); }
.msg-attachment {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  padding: 4px 10px;
  background: var(--primary-subtle);
  border-radius: 6px;
  transition: all var(--transition);
}
.msg-attachment:hover { background: var(--primary-light); }

/* ═══════════════ REPLY ═══════════════ */
.reply-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.reply-section h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.reply-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.reply-actions .btn-primary { margin-left: auto; }
.file-label { cursor: pointer; }
.file-label input[type="file"] { display: none; }
.file-name-display { font-size: 13px; color: var(--text-muted); }
.closed-notice {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

/* ═══════════════ MISC ═══════════════ */
.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
  font-weight: 500;
  padding: 10px 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
}
.success-msg {
  color: var(--success);
  font-size: 14px;
  margin-top: 10px;
  font-weight: 500;
  padding: 10px 14px;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 8px;
}
.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 56px 24px;
  font-size: 15px;
  font-weight: 500;
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-dim);
  opacity: 0.5;
}
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 56px;
  font-size: 14px;
}
.loading-spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.kb-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--warning, #ea8600);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.feedback {
  font-size: 13px;
  margin-left: 8px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
}
.feedback.success {
  color: #4ade80;
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}
.feedback.error {
  color: #f87171;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
}
.success-msg {
  color: #4ade80;
  font-size: 13px;
  font-weight: 600;
}
.restart-notice {
  color: var(--warning);
  font-size: 13px;
  font-weight: 500;
  margin-left: 8px;
}
.text-muted { color: var(--text-muted); }
code {
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  border: 1px solid var(--border);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

a { color: var(--primary); }
a:hover { color: #a78bfa; }

/* Scrollbar global */
::-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(--text-dim); }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 768px) {
  .sidebar { width: 56px; }
  .sidebar-top { padding: 16px 10px; text-align: center; }
  .logo { font-size: 0; }
  .logo::first-letter { font-size: 20px; }
  .sidebar-nav { padding: 8px 6px; }
  .nav-link { padding: 10px; justify-content: center; font-size: 0; gap: 0; }
  .nav-link svg { width: 20px; height: 20px; }
  .nav-separator { margin: 4px; }
  .sidebar-bottom { padding: 8px 6px 12px; }
  .sidebar-user-info { display: none; }
  .sidebar-user-name { display: none; }
  .sidebar-presence-btn { justify-content: center; padding: 6px; }
  .stale-tickets-btn span { display: none; }
  .stale-tickets-btn { justify-content: center; padding: 8px; }
  .container { margin-left: 56px; padding: 20px 16px; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .ticket-meta { grid-template-columns: 1fr; }
  .chat-msg { max-width: 90%; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 10px 14px; }
  .filters { flex-direction: column; padding: 14px; }
  .filters select, .filters input { width: 100%; }
  .login-card { padding: 36px 24px; }
}

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 24px; cursor: pointer; padding: 0 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 20px;
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .page-header h2 { font-size: 22px; }
  .ticket-header-top h2 { font-size: 18px; }
}
