:root {
  --bg: #f3f6fb;
  --card-bg: #ffffff;
  --text-main: #1d2a3b;
  --primary: #2458ff;
  --muted: #6c7d96;
}

body {
  margin: 0;
  background: radial-gradient(circle at 0 0, #e9f0ff 0%, var(--bg) 40%, #eef3ff 100%);
  color: var(--text-main);
  font-family: "PingFang SC", "Helvetica Neue", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
  gap: 12px;
  padding: 12px;
}

body.sidebar-collapsed .layout {
  grid-template-columns: 84px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0f254c, #173568 60%, #1f4a85);
  color: #fff;
  padding: 20px 14px;
  position: sticky;
  top: 12px;
  height: calc(100vh - 24px);
  border-radius: 18px;
  box-shadow: 0 16px 34px rgba(11, 30, 62, 0.25);
}

.sidebar-top {
  margin-bottom: 14px;
}

.brand {
  font-weight: 700;
  letter-spacing: .4px;
  margin-bottom: 16px;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  padding: 0;
  justify-content: center;
}

.nav-link-item {
  display: flex;
  gap: 8px;
  color: #dbe8ff;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.nav-link-item.active {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-weight: 600;
}

.nav-link-item:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}

.content {
  padding: 6px;
}

.content section {
  max-width: 1360px;
  margin: 0 auto;
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-label {
  display: none;
}

body.sidebar-collapsed .sidebar {
  padding-left: 10px;
  padding-right: 10px;
}

body.sidebar-collapsed .nav-link-item {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.card-glass {
  background: rgba(255,255,255,.75);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 14px;
  backdrop-filter: blur(6px);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 52px;
}

.stat-card {
  border: 1px solid #dfe8ff;
  border-radius: 14px;
}

.stat-card .label {
  color: #6a7892;
  font-size: 13px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 6px;
}

.card {
  border: 1px solid #e7edf8;
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(20, 45, 92, 0.05);
  overflow: hidden;
  font-size: 13px;
}

.card-header {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border-bottom: 1px solid #eaf0fb;
  font-weight: 600;
}

.card-body h5 {
  margin-bottom: 12px;
  font-size: 20px;
}

.form-label {
  color: #304258;
  font-weight: 600;
  font-size: 13px;
}

.form-control,
.form-select {
  border-color: #d6e1f3;
  border-radius: 10px;
  font-size: 13px;
}

.form-control:focus,
.form-select:focus {
  border-color: #8eb3ff;
  box-shadow: 0 0 0 0.2rem rgba(36, 88, 255, 0.12);
}

.btn {
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
}

.table thead th {
  background: #f5f8ff;
  color: #2f4360;
  font-weight: 700;
  border-bottom-color: #dfe8f8;
}

.table > :not(caption) > * > * {
  padding: 10px 10px;
  vertical-align: top;
  font-size: 13px;
}

.table-hover tbody tr:hover {
  background: #f7faff;
}

.text-muted,
small.text-muted {
  color: var(--muted) !important;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 20% 10%, #dce7ff, #eef3ff 50%, #f7f9ff 100%);
}

.login-card {
  width: min(92vw, 420px);
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  border: 1px solid #e6edff;
}

.pagination {
  margin-bottom: 0;
}

@media (max-width: 991.98px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0;
    gap: 0;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    width: 248px;
    z-index: 1080;
    transition: left .25s ease;
    top: 0;
    height: 100vh;
    border-radius: 0 16px 16px 0;
  }

  body.sidebar-open .sidebar {
    left: 0;
  }

  .content {
    padding: 12px;
  }
}

.badge-status-pending {
  background: #ff9f1c;
  color: #1f2937;
}

.qa-list-table {
  table-layout: fixed;
}

.qa-list-table th,
.qa-list-table td {
  text-align: left;
  vertical-align: top;
  padding-top: 10px;
  padding-bottom: 10px;
}

.qa-list-table th:nth-child(1),
.qa-list-table td:nth-child(1) {
  width: 4%;
}

.qa-list-table th:nth-child(2),
.qa-list-table td:nth-child(2) {
  width: 5%;
}

.qa-list-table th:nth-child(3),
.qa-list-table td:nth-child(3) {
  width: 11%;
}

.qa-list-table th:nth-child(4),
.qa-list-table td:nth-child(4),
.qa-list-table th:nth-child(5),
.qa-list-table td:nth-child(5) {
  width: 22%;
}

.qa-list-table th:nth-child(6),
.qa-list-table td:nth-child(6) {
  width: 11%;
}

.qa-list-table th:nth-child(7),
.qa-list-table td:nth-child(7) {
  width: 25%;
}

.qa-cell-wrap {
  white-space: normal;
  word-break: break-all;
  line-height: 1.35;
  color: #24364d;
}

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

.qa-actions .btn {
  white-space: nowrap;
  min-width: 54px;
}

.qa-actions form {
  margin: 0;
}

.chat-result {
  min-height: 88px;
  background: #f3f8ff;
  border: 1px solid #dce8ff;
  color: #17355f;
  white-space: pre-wrap;
}

.chat-table,
.monitor-table,
.users-table,
.dashboard-table {
  table-layout: fixed;
}

.chat-table th:nth-child(1),
.chat-table td:nth-child(1),
.users-table th:nth-child(1),
.users-table td:nth-child(1) {
  width: 4%;
}

.chat-table th:nth-child(2),
.chat-table td:nth-child(2) {
  width: 10%;
}

.monitor-table th:nth-child(1),
.monitor-table td:nth-child(1) {
  width: 4%;
}

.chat-table th:nth-child(3),
.chat-table td:nth-child(3) {
  width: 26%;
}

.chat-table th:nth-child(4),
.chat-table td:nth-child(4) {
  width: 48%;
}

.chat-table th:nth-child(5),
.chat-table td:nth-child(5) {
  width: 10%;
}

.monitor-table th:nth-child(2),
.monitor-table td:nth-child(2) {
  width: 4%;
}

.monitor-table th:nth-child(3),
.monitor-table td:nth-child(3) {
  width: 11%;
}

.monitor-table th:nth-child(4),
.monitor-table td:nth-child(4) {
  width: 11%;
}

.monitor-table th:nth-child(5),
.monitor-table td:nth-child(5) {
  width: 12%;
}

.monitor-table th:nth-child(6),
.monitor-table td:nth-child(6) {
  width: 14%;
}

.monitor-table th:nth-child(7),
.monitor-table td:nth-child(7) {
  width: 8%;
}

.monitor-table th:nth-child(8),
.monitor-table td:nth-child(8) {
  width: 6%;
}

.monitor-table th:nth-child(9),
.monitor-table td:nth-child(9) {
  width: 8%;
}

.monitor-table th:nth-child(10),
.monitor-table td:nth-child(10) {
  width: 10%;
}

.monitor-table th:nth-child(11),
.monitor-table td:nth-child(11) {
  width: 16%;
}

.monitor-status-dropdown {
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.35;
}

.monitor-filter-card {
  overflow: visible;
  min-height: 182px;
}

.monitor-filter-card .card-body {
  overflow: visible;
}

.monitor-filter-actions {
  gap: 10px;
}

.monitor-filter-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1.2fr 1.8fr 1fr 1fr 1fr 1.8fr;
}

.monitor-date-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
}

@media (max-width: 1199.98px) {
  .monitor-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.btn-priority-reply {
  color: #7a3b00;
  background: linear-gradient(180deg, #ffd59a, #ffbd59);
  border: 1px solid #f39a2d;
  box-shadow: 0 0 0 rgba(255, 153, 0, 0.45);
  animation: flamePulse 1.25s ease-in-out infinite;
}

.btn-priority-reply:hover,
.btn-priority-reply:focus {
  color: #6a2f00;
  background: linear-gradient(180deg, #ffca79, #ffad39);
  border-color: #ea8600;
}

.btn-priority-reply .bi-fire {
  margin-right: 4px;
  font-size: 0.85rem;
}

@keyframes flamePulse {
  0% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 rgba(255, 153, 0, 0.25);
  }
  50% {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 0 14px rgba(255, 143, 0, 0.45);
  }
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 rgba(255, 153, 0, 0.25);
  }
}

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

.users-table th:nth-child(2),
.users-table td:nth-child(2) {
  width: 14%;
}

.users-table th:nth-child(3),
.users-table td:nth-child(3) {
  width: 11%;
}

.users-table th:nth-child(4),
.users-table td:nth-child(4),
.users-table th:nth-child(5),
.users-table td:nth-child(5) {
  width: 12%;
}

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

.users-table th:nth-child(7),
.users-table td:nth-child(7) {
  width: 14%;
}

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

.users-table th:nth-child(9),
.users-table td:nth-child(9) {
  width: 8%;
}

.users-filter-card {
  overflow: visible;
}

.users-filter-card .card-body {
  overflow: visible;
}

.users-filter-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1.2fr 1.4fr 1.1fr 1.1fr;
}

.users-filter-dropdown {
  max-height: 240px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.35;
}

@media (max-width: 1199.98px) {
  .users-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.pagination .page-link {
  border-radius: 8px;
  font-size: 12px;
}

.op-waiting-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.op-waiting-card {
  width: min(92vw, 460px);
  background: #fff;
  border-radius: 14px;
  padding: 22px 18px;
  text-align: center;
  border: 1px solid #d8e3fa;
  box-shadow: 0 16px 40px rgba(12, 33, 73, 0.18);
}

body.op-waiting {
  cursor: wait;
}
