:root {
  --bg: #edf2ff;
  --bg-soft: #f7f9ff;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --line: #d9e2f0;
  --line-strong: #c8d3e5;
  --text: #1f2940;
  --muted: #6b7891;
  --accent: #6d28d9;
  --accent-2: #2563eb;
  --accent-soft: #eef2ff;
  --danger: #dc2626;
  --success: #0f766e;
  --shadow: 0 20px 50px rgba(64, 85, 138, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(109, 40, 217, 0.16), transparent 26%),
    linear-gradient(180deg, #eaf0ff, #f7f9ff 50%, #eef4ff);
  color: var(--text);
  font-family: "Outfit", sans-serif;
  font-size: 14px;
}

.app-background {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.36), transparent 28%),
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.45), transparent 10%);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card,
.sidebar,
.workspace-topbar,
.card-shell,
.table-shell,
.editor-shell,
.stats-card,
.modal-card {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.login-card {
  width: min(100%, 380px);
  border-radius: 20px;
  padding: 22px;
}

.brand-mark {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.login-subtitle,
.subtle,
.status-line {
  color: var(--muted);
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  position: relative;
  z-index: 1;
}

.sidebar {
  border-radius: 24px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-brand {
  padding: 8px 10px 18px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: #3b1f6b;
}

.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-label {
  padding: 0 10px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7b88a1;
}

.sidebar-link {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  border-radius: 14px;
  font-size: 14px;
  color: #334155;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.sidebar-link.active {
  background: linear-gradient(90deg, rgba(109, 40, 217, 0.92), rgba(37, 99, 235, 0.92));
  color: #fff;
  box-shadow: 0 12px 26px rgba(91, 67, 183, 0.22);
}

.sidebar-link:hover {
  transform: translateX(2px);
}

.workspace {
  min-width: 0;
}

.workspace-topbar {
  border-radius: 22px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.session-badge {
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  font-size: 12px;
}

.workspace-filter-bar {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}

.workspace-filter-bar.d-none {
  display: none !important;
}

.filter-multiselect {
  min-width: 160px;
  max-width: 220px;
  height: 72px;
  font-size: 0.82rem;
}

.helpdesk-analytics-filters {
  display: grid;
  grid-template-columns: minmax(150px, 200px) repeat(3, minmax(220px, 1fr));
  align-items: start;
  gap: 14px;
  width: 100%;
}

.helpdesk-analytics-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 12px;
}

.helpdesk-import-option {
  display: grid;
  gap: 4px;
  min-width: 92px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.helpdesk-analytics-filters .filter-group {
  min-width: 0;
}

.analytics-filter-search {
  margin-bottom: 8px;
}

.analytics-checklist {
  display: grid;
  gap: 6px;
  max-height: 184px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.68);
}

.analytics-check-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  min-width: 0;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
}

.analytics-check-option:hover {
  background: rgba(37, 99, 235, 0.08);
}

.analytics-check-option:has(input:checked) {
  background: rgba(37, 99, 235, 0.12);
  outline: 1px solid rgba(37, 99, 235, 0.22);
}

.analytics-check-option span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.analytics-check-option strong,
.analytics-check-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-check-option small {
  color: var(--muted);
  font-size: 11px;
}

.analytics-agent-cell {
  display: block;
  min-width: 0;
}

.analytics-agent-toggle {
  padding: 3px 8px;
  font-size: 12px;
}

.analytics-filter-empty {
  padding: 8px;
  font-size: 12px;
}

.helpdesk-leaderboard-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.helpdesk-leaderboard-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.helpdesk-leaderboard-table th,
.helpdesk-leaderboard-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.helpdesk-leaderboard-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7f9ff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.helpdesk-leaderboard-table .col-period,
.helpdesk-leaderboard-table .col-period-sub {
  min-width: 96px;
  text-align: left;
}

.helpdesk-leaderboard-table .col-action {
  left: 0;
  min-width: 84px;
  text-align: left;
}

.helpdesk-leaderboard-table .col-rank {
  left: 84px;
  min-width: 64px;
  text-align: left;
}

.helpdesk-leaderboard-table .col-agent {
  left: 148px;
  min-width: 280px;
  max-width: 320px;
}

.helpdesk-leaderboard-table .col-tickets {
  left: 428px;
  min-width: 132px;
  text-align: left;
  border-right: 1px solid var(--line);
}

.helpdesk-leaderboard-table .sticky-left {
  position: sticky;
  z-index: 2;
}

.helpdesk-leaderboard-table thead .sticky-left {
  z-index: 4;
}

.helpdesk-leaderboard-table tbody tr:hover td {
  background: #f8fbff;
}

.helpdesk-leaderboard-table .summary-row td {
  background: rgba(109, 40, 217, 0.08);
  font-weight: 800;
}

.analytics-agent-detail-row td {
  background: rgba(248, 251, 255, 0.96);
  padding: 14px;
}

.analytics-ticket-detail {
  display: grid;
  gap: 10px;
}

.analytics-ticket-detail-title {
  font-weight: 800;
}

.analytics-ticket-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.analytics-ticket-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.analytics-ticket-table th,
.analytics-ticket-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.analytics-ticket-table th {
  color: var(--muted);
  font-size: 11px;
}

.leaderboard-section {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.workspace-content {
  display: grid;
  gap: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.stats-card {
  border-radius: 18px;
  padding: 16px;
}

.stats-label {
  color: var(--muted);
  font-size: 12px;
}

.stats-value {
  margin-top: 6px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  gap: 14px;
}

.admin-users-grid {
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
}

.admin-users-table-shell {
  grid-column: 1 / -1;
}

.card-shell,
.table-shell,
.editor-shell {
  border-radius: 20px;
  padding: 14px;
}

.section-title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.editor-shell .form-control,
.editor-shell .form-select,
.card-shell .form-control,
.card-shell .form-select {
  min-height: 38px;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.toolbar-row .form-control,
.toolbar-row .form-select {
  flex: 1 1 240px;
  min-width: 0;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.filter-chip {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.filter-chip.active {
  border-color: rgba(37, 99, 235, 0.42);
  background: var(--accent-soft);
  color: var(--accent-2);
}

.selected-summary {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.selected-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.check-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.9);
}

.check-pill span {
  flex: 1 1 auto;
  min-width: 0;
}

.modal-priority-select,
[data-group-member-priority] {
  width: 108px;
}

.check-pill input,
.admin-table .form-check-input {
  margin: 0;
}

.table-shell {
  overflow: hidden;
}

.admin-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--line);
  margin-bottom: 0;
}

.admin-table thead th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f2f5fb;
  border: 1px solid var(--line);
  font-size: 12px;
}

.chip.primary {
  background: #eef2ff;
  color: #4338ca;
}

.chip.last {
  background: #f8fafc;
  color: #475569;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.status-line {
  min-height: 18px;
  font-size: 12px;
}

.status-line[data-tone="success"] {
  color: var(--success);
}

.status-line[data-tone="error"] {
  color: var(--danger);
}

.totp-setup-box {
  display: grid;
  gap: 8px;
}

.totp-qr {
  width: 184px;
  height: 184px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}

.permission-check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-right: 10px;
  white-space: nowrap;
}

.admin-users-table-shell .admin-table {
  table-layout: fixed;
  width: 100%;
}

.admin-users-table-shell .admin-table th:nth-child(1),
.admin-users-table-shell .admin-table td:nth-child(1) {
  width: 22%;
  overflow-wrap: anywhere;
}

.admin-users-table-shell .admin-table th:nth-child(2),
.admin-users-table-shell .admin-table td:nth-child(2),
.admin-users-table-shell .admin-table th:nth-child(3),
.admin-users-table-shell .admin-table td:nth-child(3),
.admin-users-table-shell .admin-table th:nth-child(4),
.admin-users-table-shell .admin-table td:nth-child(4) {
  width: 10%;
}

.admin-users-table-shell .admin-table th:nth-child(5),
.admin-users-table-shell .admin-table td:nth-child(5) {
  width: 18%;
}

.admin-users-table-shell .admin-table th:nth-child(6),
.admin-users-table-shell .admin-table td:nth-child(6) {
  width: 16%;
}

.admin-users-table-shell .admin-table th:nth-child(7),
.admin-users-table-shell .admin-table td:nth-child(7) {
  width: 12%;
  overflow-wrap: anywhere;
}

.admin-users-table-shell .admin-table th:nth-child(8),
.admin-users-table-shell .admin-table td:nth-child(8) {
  width: 220px;
}

.admin-actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 29, 49, 0.46);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 1000;
}

.modal-card {
  width: min(100%, 980px);
  max-height: min(90vh, 900px);
  overflow: auto;
  border-radius: 24px;
  padding: 18px;
}

.modal-overlay-nested {
  z-index: 1010;
}

.livechat-priority-modal {
  width: min(100%, 720px);
}

.priority-bucket-list {
  display: grid;
  gap: 10px;
}

.priority-bucket {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.88);
}

.priority-bucket-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.priority-bucket-head .form-select {
  width: 132px;
}

.check-pill-muted {
  background: rgba(248, 250, 252, 0.92);
}

.helpdesk-chat-modal {
  width: min(100%, 1120px);
}

.live-ticket-modal {
  width: min(100%, 1280px);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
}

.profile-card,
.profile-form {
  display: grid;
  gap: 12px;
}

.profile-hero {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.profile-photo {
  width: 88px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-2);
  border: 1px solid var(--line);
  font-size: 24px;
  font-weight: 700;
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
  margin-top: 6px;
}

.profile-form .form-control:disabled {
  background: #f8fafc;
  color: var(--muted);
}

.profile-actions {
  display: grid;
  gap: 8px;
}

.profile-label {
  color: var(--muted);
  font-size: 12px;
}

.credentials-box {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.8);
  font-size: 12px;
  white-space: pre-wrap;
}

.helpdesk-ticket-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.ticket-modal-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 14px;
  align-items: start;
}

.ticket-thread-panel {
  min-width: 0;
}

.helpdesk-chat-thread {
  display: grid;
  gap: 10px;
}

.helpdesk-chat-event {
  display: grid;
  justify-items: start;
  gap: 4px;
}

.helpdesk-chat-event.agent {
  justify-items: end;
}

.helpdesk-chat-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.helpdesk-chat-bubble {
  max-width: min(720px, 100%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  white-space: pre-wrap;
}

.helpdesk-chat-event.agent .helpdesk-chat-bubble {
  background: #eef2ff;
  border-color: rgba(37, 99, 235, 0.18);
}

.helpdesk-chat-event.private .helpdesk-chat-bubble {
  background: #fff7ed;
  border-color: #fed7aa;
}

.helpdesk-chat-event.system {
  justify-items: center;
}

.helpdesk-chat-event.system .helpdesk-chat-bubble {
  max-width: 760px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

.tickets-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.tickets-workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.tickets-workspace-collapsed {
  grid-template-columns: 54px minmax(0, 1fr);
}

.tickets-left-rail {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 22px;
  min-height: 420px;
  border-radius: 20px;
  padding: 16px 14px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.tickets-left-rail.collapsed {
  width: 54px;
  min-height: 54px;
  padding: 10px;
}

.tickets-left-rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.tickets-rail-toggle {
  width: 30px;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tickets-rail-section {
  display: grid;
  gap: 7px;
}

.tickets-rail-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.tickets-rail-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  padding: 7px 8px;
  background: transparent;
  color: #4b5565;
  text-align: left;
  cursor: pointer;
}

.tickets-rail-item:hover,
.tickets-rail-item.active {
  background: var(--accent-soft);
  color: var(--accent-2);
}

.tickets-rail-count {
  min-width: 26px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  background: #e5e7eb;
  color: #687083;
  font-size: 12px;
  font-weight: 700;
}

.tickets-rail-item.active .tickets-rail-count {
  background: #dbeafe;
  color: var(--accent-2);
}

.tickets-merge-log-section {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.tickets-merge-log-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.tickets-merge-log-item {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.74);
  font-size: 12px;
}

.tickets-merge-log-item strong,
.tickets-merge-log-item span,
.tickets-merge-log-item small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tickets-merge-log-item span,
.tickets-merge-log-item small,
.tickets-merge-log-empty {
  color: var(--muted);
}

.tickets-merge-log-empty {
  font-size: 12px;
}

.tickets-main {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.tickets-filter-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px;
  border-radius: 20px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.tickets-filter-group {
  display: grid;
  gap: 6px;
}

.tickets-filter-group span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.tickets-date-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.tickets-filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
}

.tickets-export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tickets-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: min(100%, 360px);
}

.tickets-pager-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tickets-page-chip {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ticket-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ticket-tag {
  font-size: 11px;
}

.tickets-sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tickets-sort-button span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tickets-sort-button i {
  color: var(--muted);
  font-size: 12px;
}

.workflows-page {
  display: grid;
  gap: 14px;
}

.workflows-table th,
.workflows-table td {
  vertical-align: middle;
}

.workflow-analytics-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.workflow-name-cell {
  display: grid;
  gap: 3px;
  min-width: min(100%, 280px);
}

.workflow-name-cell span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.workflow-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.workflow-inline-config {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.workflow-inline-config label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.workflow-inline-config-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.workflow-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 48px;
  height: 26px;
  margin: 0;
}

.workflow-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.workflow-switch span {
  width: 48px;
  height: 26px;
  border-radius: 999px;
  background: #cbd5e1;
  border: 1px solid var(--line-strong);
  transition: background-color 140ms ease;
}

.workflow-switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(31, 41, 64, 0.2);
  transition: transform 140ms ease;
}

.workflow-switch input:checked + span {
  background: var(--success);
  border-color: rgba(15, 118, 110, 0.36);
}

.workflow-switch input:checked + span::after {
  transform: translateX(22px);
}

.workflow-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr)) auto;
  gap: 10px;
  align-items: end;
}

.workflow-field-wide {
  grid-column: span 2;
}

.workflow-message-group {
  grid-column: 1 / -1;
}

.workflow-message-input {
  min-height: 168px;
  resize: vertical;
}

.workflow-form-actions {
  display: flex;
  align-items: end;
}

.tickets-sort-button.active {
  color: var(--accent-2);
}

.tickets-sort-button.active i {
  color: var(--accent-2);
}

.tickets-table th:first-child,
.tickets-table td:first-child {
  width: 84px;
}

.ticket-subject-cell,
.ticket-agent-cell {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.ticket-subject-cell strong,
.ticket-agent-cell strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.ticket-subject-cell small,
.ticket-agent-cell small {
  color: var(--muted);
}

.ticket-subject-cell .chip {
  width: fit-content;
}

.ticket-sidebar {
  display: grid;
  gap: 12px;
  max-height: min(72vh, 760px);
  overflow: auto;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.ticket-sidebar-head {
  display: grid;
  gap: 2px;
}

.ticket-sidebar-group {
  display: grid;
  gap: 8px;
}

.ticket-sidebar-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 13px;
}

.ticket-sidebar-group-head span {
  color: var(--muted);
  font-size: 12px;
}

.requester-ticket-list {
  display: grid;
  gap: 6px;
}

.requester-ticket-link {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.requester-ticket-link:hover,
.requester-ticket-link.current {
  border-color: rgba(37, 99, 235, 0.34);
  background: var(--accent-soft);
}

.requester-ticket-link span:first-child {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.requester-ticket-link span,
.requester-ticket-link small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.requester-ticket-link small {
  color: var(--muted);
}

.log-target,
.log-agent-email {
  font-weight: 600;
}

.log-details {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.log-row {
  display: grid;
  gap: 6px;
}

.log-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.log-label {
  font-size: 12px;
  color: var(--muted);
}

.log-value {
  min-width: 0;
}

.log-stack {
  display: grid;
  gap: 10px;
}

.log-agent-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.analytics-filter-bar {
  display: grid;
  gap: 12px;
}

.analytics-filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(170px, 1fr));
  gap: 10px;
}

.analytics-filter-grid label,
.analytics-filter-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.analytics-filter-grid label span,
.analytics-filter-group > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.analytics-filter-group label {
  margin: 0;
}

.analytics-agent-filter-matrix {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  grid-template-areas:
    "include-search exclude-search"
    "include-list exclude-list";
  gap: 10px 14px;
  align-items: start;
}

.analytics-agent-filter-search-include {
  grid-area: include-search;
}

.analytics-agent-filter-search-exclude {
  grid-area: exclude-search;
}

.analytics-agent-filter-list-include {
  grid-area: include-list;
}

.analytics-agent-filter-list-exclude {
  grid-area: exclude-list;
}

.livechat-analytics-checklist {
  max-height: 132px;
}

.analytics-agent-option-grid {
  display: grid;
  grid-template-columns: minmax(110px, 0.9fr) minmax(150px, 1.1fr);
  gap: 10px;
  align-items: center;
}

.analytics-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.analytics-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.analytics-card-grid,
.analytics-top-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.analytics-top-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analytics-card,
.top5-panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.analytics-card-prev {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.analytics-delta {
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.analytics-delta.good {
  color: #047857;
  background: rgba(16, 185, 129, 0.14);
}

.analytics-delta.bad {
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.14);
}

.analytics-delta.neutral {
  color: var(--muted);
  background: rgba(100, 116, 139, 0.12);
}

.top5-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.top5-row:last-child {
  border-bottom: 0;
}

.top5-rank {
  display: grid;
  place-items: center;
  width: 26px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.top5-agent {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.top5-name,
.top5-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top5-name {
  font-weight: 600;
}

.top5-sub {
  color: var(--muted);
  font-size: 11px;
}

.analytics-agent-main {
  font-weight: 700;
}

.analytics-agent-cell {
  min-width: 260px;
}

.analytics-agent-copy {
  min-width: 0;
}

.analytics-agent-sub {
  color: var(--muted);
  font-size: 12px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top5-value {
  color: var(--muted);
  white-space: nowrap;
}

.analytics-table-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.analytics-leaderboard-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.analytics-table {
  min-width: 980px;
}

.analytics-table th,
.analytics-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.analytics-table th button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
}

.analytics-account-row td {
  background: rgba(109, 40, 217, 0.08);
  font-weight: 700;
}

.analytics-error {
  color: var(--danger);
}

.helpdesk-analytics-loading {
  display: grid;
  gap: 10px;
  max-width: 920px;
}

.helpdesk-analytics-loading-head,
.helpdesk-analytics-loading-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: space-between;
}

.helpdesk-analytics-loading-meta {
  color: var(--muted);
  font-size: 13px;
}

.helpdesk-analytics-progress {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
}

@media (max-width: 1199.98px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    flex-direction: row;
    overflow: auto;
    padding: 12px;
  }

  .sidebar-group {
    min-width: 220px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-grid,
  .modal-layout,
  .ticket-modal-layout {
    grid-template-columns: 1fr;
  }

  .ticket-sidebar {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 14px;
  }

  .analytics-filter-grid,
  .analytics-card-grid,
  .helpdesk-analytics-filters,
  .tickets-filter-bar,
  .workflow-analytics-filter-grid,
  .workflow-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .helpdesk-leaderboard-wrapper {
    max-width: calc(100vw - 32px);
  }

  .log-grid-two {
    grid-template-columns: 1fr;
  }
}

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

  .analytics-filter-grid,
  .analytics-card-grid,
  .analytics-top-grid,
  .helpdesk-analytics-filters,
  .tickets-filter-bar,
  .workflow-analytics-filter-grid,
  .workflow-form-grid,
  .workflow-inline-config-row {
    grid-template-columns: 1fr;
  }

  .tickets-workspace {
    grid-template-columns: 1fr;
  }

  .tickets-left-rail {
    position: static;
    min-height: auto;
  }

  .tickets-left-rail.collapsed {
    width: 100%;
  }

  .tickets-pager,
  .tickets-toolbar {
    align-items: stretch;
  }

  .tickets-pager {
    flex-direction: column;
  }

  .analytics-agent-filter-matrix {
    grid-template-columns: 1fr;
    grid-template-areas:
      "include-search"
      "include-list"
      "exclude-search"
      "exclude-list";
  }

  .analytics-switch {
    margin-left: 0;
  }

  .toolbar-row {
    align-items: stretch;
  }

  .tickets-toolbar {
    flex-direction: column;
  }

  .workspace-topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
