/* ==========================================================================
   QA Monitoring — Design tokens
   Dark slate sidebar, cool light workspace, single teal accent.
   Status colors are fixed by spec: PENDING amber / PASS green /
   CONFIRMED red / REJECTED gray.
   ========================================================================== */
:root {
  --color-bg: #F4F6F9;
  --color-surface: #FFFFFF;
  --color-border: #E3E8EF;
  --color-text: #1B2430;
  --color-text-muted: #64748B;

  /* Row dividers for every table / list panel in the app (Overview's
     Recent QA Reviews, Customer Report, Human Review, SOP Management,
     Language Report, Issue Distribution, etc.) — kept as shared
     tokens so all of them stay visually consistent from one place. */
  --color-row-divider: #D6DCE4;
  --color-row-divider-header: #BCC5D1;

  --color-sidebar: #111A27;
  --color-sidebar-text: #8FA0B8;
  --color-sidebar-text-active: #FFFFFF;

  --color-accent: #0D9488;
  --color-accent-soft: #E6F5F3;

  --status-pending: #F59E0B;
  --status-pending-bg: #FEF3E2;
  --status-pass: #16A34A;
  --status-pass-bg: #E9F8EE;
  --status-confirmed: #DC2626;
  --status-confirmed-bg: #FDECEC;
  --status-rejected: #6B7280;
  --status-rejected-bg: #EEF0F2;

  --font-display: "Manrope", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;

  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ==========================================================================
   Shell layout
   ========================================================================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 22px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--color-accent);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14.5px;
  color: #ffffff;
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 11.5px;
  color: #6E82A0;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: var(--color-sidebar-text);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
}

.nav-item.is-active {
  background: rgba(13, 148, 136, 0.18);
  color: var(--color-sidebar-text-active);
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
  flex-shrink: 0;
}

.nav-item.is-active .nav-dot {
  background: var(--color-accent);
  opacity: 1;
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.25);
}

.sidebar-footer {
  font-size: 11px;
  line-height: 1.5;
  color: #56698A;
  padding: 14px 8px 4px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 12px;
}

/* ---------------- Main column ---------------- */
.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 68px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-page-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.lang-switch {
  display: flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 3px;
}

.lang-option {
  border: none;
  background: transparent;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: background 0.12s ease, color 0.12s ease;
}

.lang-option.is-active {
  background: var(--color-sidebar);
  color: #ffffff;
}

.current-user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.3;
}

.current-user-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.current-user-name {
  font-size: 13px;
  font-weight: 600;
}

/* ==========================================================================
   Page content
   ========================================================================== */
.page {
  padding: 26px 28px 60px 28px;
}

.page.is-hidden {
  display: none;
}

.page-heading h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  margin: 0 0 4px 0;
}

.page-heading p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 13.5px;
}

/* ---------------- Stat cards ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin: 22px 0;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 16px 14px 16px;
  box-shadow: var(--shadow-card);
  border-left: 3px solid var(--stat-accent, var(--color-accent));
}

.stat-card-label {
  font-size: 11.5px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  margin-top: 6px;
}

.stat-grid-5 {
  grid-template-columns: repeat(5, 1fr);
}

@media (max-width: 1100px) {
  .stat-grid-5 { grid-template-columns: repeat(3, 1fr); }
}

.stat-card-clickable {
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.stat-card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(16, 24, 40, 0.1);
}

.date-filter-label {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------------- Panels (tables / lists) ---------------- */
.panel-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  align-items: start;
}

/* Pages that put a panel-grid (or a single panel) directly under the
   heading — with no stat-grid/filters in between — need their own
   top spacing, or the card's top edge overlaps the subtitle text. */
.page-heading + .panel-grid,
.page-heading + .panel {
  margin-top: 22px;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 8px 18px;
  box-shadow: var(--shadow-card);
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px 0;
}

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

/* Keeps any table wider than its panel (e.g. SOP Management's 10
   columns, Human Review's Comment column) scrolling inside the
   panel instead of pushing the whole page wider. */
.table-scroll-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table th {
  text-align: left;
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 8px;
  border-bottom: 1.5px solid var(--color-row-divider-header);
  border-right: 1px solid var(--color-row-divider);
}

.data-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--color-row-divider);
  border-right: 1px solid var(--color-row-divider);
}

.data-table th:last-child,
.data-table td:last-child {
  border-right: none;
}

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

.empty-row td {
  color: var(--color-text-muted);
  text-align: center;
  padding: 22px 8px;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-badge.pending { color: var(--status-pending); background: var(--status-pending-bg); }
.status-badge.pass { color: var(--status-pass); background: var(--status-pass-bg); }
.status-badge.confirmed { color: var(--status-confirmed); background: var(--status-confirmed-bg); }
.status-badge.rejected { color: var(--status-rejected); background: var(--status-rejected-bg); }

/* Issue distribution bars */
.bar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bar-row {
  padding: 10px 0;
  border-bottom: 1px solid var(--color-row-divider);
}

.bar-row:first-child {
  padding-top: 0;
}

.bar-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.bar-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}

.bar-row-top .bar-count {
  color: var(--color-text-muted);
  font-weight: 600;
}

.bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--color-bg);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--color-accent);
}

/* ---------------- Chat upload bar (QA Review page) ---------------- */
.upload-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 20px 0 14px 0;
  flex-wrap: wrap;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-accent);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease;
}

.upload-button:hover {
  background: #0B7C72;
}

.upload-bar-right {
  justify-content: space-between;
}

.upload-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.upload-hint {
  font-size: 12px;
  color: var(--color-text-muted);
}

.search-box {
  margin-left: auto;
}

.search-box input {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  min-width: 240px;
  background: var(--color-surface);
  color: var(--color-text);
}

.search-box input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.upload-feedback {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

.upload-feedback.is-hidden {
  display: none;
}

.upload-feedback.is-success {
  background: var(--status-pass-bg);
  color: var(--status-pass);
}

.upload-feedback.is-error {
  background: var(--status-confirmed-bg);
  color: var(--status-confirmed);
}

.clickable-row {
  cursor: pointer;
  transition: background 0.1s ease;
}

.clickable-row:hover {
  background: var(--color-accent-soft);
}

/* ---------------- Conversation modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 26, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.is-hidden {
  display: none;
}

.modal-box {
  width: 560px;
  max-width: calc(100vw - 40px);
  max-height: 80vh;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-chat-id {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
}

.modal-chat-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 3px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  color: var(--color-text-muted);
  padding: 4px 8px;
}

.modal-close:hover {
  color: var(--color-text);
}

.modal-conversation {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg-row {
  display: flex;
}

.msg-row.msg-agent {
  justify-content: flex-end;
}

.msg-bubble {
  max-width: 75%;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--color-bg);
}

.msg-row.msg-agent .msg-bubble {
  background: var(--color-accent-soft);
}

.msg-sender {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  margin-bottom: 3px;
}

.msg-text {
  font-size: 13px;
  line-height: 1.5;
}

.msg-time {
  font-size: 10.5px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ---------------- QA Review — filters ---------------- */
.qa-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.qa-filter-select,
.qa-filter-search {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

.qa-filter-select {
  min-width: 140px;
}

.qa-filter-search {
  flex: 1;
  min-width: 200px;
}

.qa-filter-select:focus,
.qa-filter-search:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* ---------------- QA Review — 3-column layout ---------------- */
.qa-columns {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 14px;
  height: 600px;
}

.qa-col {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.qa-col-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.qa-conversation-meta {
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-top: 3px;
}

.qa-col-body {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
}

.qa-conversation-scroll {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qa-empty-state,
.qa-list-empty {
  color: var(--color-text-muted);
  font-size: 12.5px;
  text-align: center;
  padding: 30px 12px;
}

/* Chat list items */
.qa-list-item {
  width: 100%;
  display: block;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 10px;
  margin-bottom: 4px;
}

.qa-list-item:hover {
  background: var(--color-bg);
}

.qa-list-item.is-active {
  background: var(--color-accent-soft);
  border-color: var(--color-accent);
}

.qa-list-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.qa-list-chat-id {
  font-size: 12.5px;
  font-weight: 700;
}

.qa-list-item-bottom {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-muted);
}

/* Analysis column */
.qa-fact-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--color-border);
  font-size: 12.5px;
}

.qa-fact-label {
  color: var(--color-text-muted);
  font-weight: 500;
}

.qa-fact-value {
  font-weight: 600;
}

.qa-fact-block {
  padding: 10px 4px;
}

.qa-fact-block .qa-fact-label {
  display: block;
  margin-bottom: 5px;
}

.qa-reason-text {
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0;
}

.qa-resolution-box {
  margin-top: 14px;
  padding: 12px;
  background: var(--color-bg);
  border-radius: 10px;
}

.qa-resolution-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 6px;
}

.qa-resolution-line {
  font-size: 12px;
  line-height: 1.7;
  color: var(--color-text);
}

.qa-change-decision-btn {
  margin-top: 8px;
  font-size: 11.5px;
  padding: 6px 12px;
}

.qa-action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.qa-action-btn {
  flex: 1;
  border: none;
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.qa-action-pass { background: var(--status-pass-bg); color: var(--status-pass); }
.qa-action-pass:hover { background: #D6F1DF; }

.qa-action-confirm { background: var(--status-confirmed-bg); color: var(--status-confirmed); }
.qa-action-confirm:hover { background: #FADCDC; }

.qa-action-reject { background: var(--status-rejected-bg); color: var(--status-rejected); }
.qa-action-reject:hover { background: #E3E6EA; }

.qa-comment-box {
  margin-top: 14px;
}

.qa-comment-label {
  display: block;
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.qa-comment-input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12.5px;
  resize: vertical;
}

.qa-comment-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

.qa-comment-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.qa-submit-btn {
  background: var(--color-accent);
  color: #ffffff;
}

.qa-submit-btn:hover {
  background: #0B7C72;
}

@media (max-width: 1100px) {
  .qa-columns {
    grid-template-columns: 1fr;
    height: auto;
  }
  .qa-col {
    height: 360px;
  }
}

.qa-comment-cell {
  max-width: 220px;
  white-space: normal;
  color: var(--color-text-muted);
}

.sop-content-cell {
  max-width: 280px;
  white-space: normal;
  color: var(--color-text-muted);
}

.sop-action-cell {
  white-space: nowrap;
}

.sop-link-btn {
  border: none;
  background: transparent;
  color: var(--color-accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
}

.sop-link-btn:hover {
  text-decoration: underline;
}

.sop-link-danger {
  color: var(--status-confirmed);
}

.sop-create-hint {
  font-size: 11px;
  color: var(--color-text-muted);
  margin: 10px 0 0 0;
  line-height: 1.5;
}

.sop-edit-field {
  margin-top: 12px;
}

.sop-edit-field input[type="number"] {
  width: 100px;
}

.sop-edit-checkboxes {
  display: flex;
  gap: 18px;
  margin-top: 14px;
}

.sop-checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
}

/* ---------------- CS Performance — agent leaderboard ---------------- */
.leaderboard-row-wrap {
  border-bottom: 1px solid var(--color-row-divider);
}

.leaderboard-row-wrap:last-child {
  border-bottom: none;
}

.leaderboard-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border: none;
  background: transparent;
  text-align: left;
}

.leaderboard-row:hover {
  background: var(--color-bg);
}

.leaderboard-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.leaderboard-main {
  flex: 1;
  min-width: 0;
}

.leaderboard-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.leaderboard-name {
  font-size: 13px;
  font-weight: 600;
}

.leaderboard-score {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  min-width: 44px;
  text-align: right;
}

.leaderboard-mistake-list {
  padding: 4px 4px 10px 44px;
}

.leaderboard-mistake-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: none;
  background: var(--color-bg);
  border-radius: 8px;
  margin-bottom: 4px;
  text-align: left;
}

.leaderboard-mistake-item:hover {
  background: var(--status-confirmed-bg);
}

.leaderboard-mistake-item:last-child {
  margin-bottom: 0;
}

.leaderboard-mistake-chat-id {
  font-size: 12px;
  font-weight: 700;
  min-width: 90px;
}

.leaderboard-mistake-meta {
  flex: 1;
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.leaderboard-mistake-date {
  font-size: 11px;
  color: var(--color-text-muted);
}

/* ---------------- Customer Report — customer-grouped chat activity ---------------- */
.cr-panel-hint {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin: -6px 0 10px 0;
}

.cr-customer-header-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1.4fr 1.2fr 20px;
  gap: 8px;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  border-bottom: 1.5px solid var(--color-row-divider-header);
}

.cr-customer-row-wrap {
  border-bottom: 1px solid var(--color-row-divider);
}

.cr-customer-row-wrap:last-child {
  border-bottom: none;
}

.cr-customer-row {
  width: 100%;
  display: grid;
  grid-template-columns: 2fr 1fr 1.4fr 1.2fr 20px;
  align-items: center;
  gap: 8px;
  padding: 12px 10px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 12.5px;
}

.cr-customer-row:hover {
  background: var(--color-bg);
}

.cr-customer-name {
  font-weight: 600;
  color: var(--color-accent);
}

.cr-customer-visits {
  font-weight: 700;
  font-family: var(--font-display);
}

.cr-issue-badge {
  display: inline-block;
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
}

.cr-customer-last-chat {
  color: var(--color-text-muted);
  font-size: 12px;
}

.cr-customer-chevron {
  font-style: normal;
  font-size: 10px;
  color: var(--color-text-muted);
  text-align: right;
}

.cr-chat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  padding: 4px 10px 14px 10px;
}

.cr-chat-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--color-bg);
  text-align: left;
}

.cr-chat-card:hover {
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

.cr-chat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.cr-chat-card-id {
  font-size: 12px;
  font-weight: 700;
}

.cr-chat-card-issue {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.cr-chat-card-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: 3px;
}

.cr-chat-card-date {
  font-size: 10.5px;
  color: var(--color-text-muted);
}

@media (max-width: 720px) {
  .cr-customer-header-row,
  .cr-customer-row {
    grid-template-columns: 1.6fr 0.6fr 1fr 20px;
  }
  .cr-customer-last-chat {
    display: none;
  }
}

/* ---------------- Settings page ---------------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-top: 22px;
  max-width: 900px;
}

.settings-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.settings-card h2 {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 700;
  margin: 0 0 8px 0;
}

.settings-card p {
  font-size: 12.5px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0 0 16px 0;
}

.settings-btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
}

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

.settings-btn-neutral:hover {
  background: #EAEEF3;
}

.settings-btn-danger {
  background: var(--status-confirmed-bg);
  color: var(--status-confirmed);
}

.settings-btn-danger:hover {
  background: #FADCDC;
}

.threshold-control {
  display: flex;
  align-items: center;
  gap: 12px;
}

.threshold-control input[type="range"] {
  flex: 1;
  accent-color: var(--color-accent);
}

.threshold-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  min-width: 40px;
  text-align: right;
}

.category-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.category-chip {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.category-add-row {
  display: flex;
  gap: 8px;
}

.category-add-row input {
  flex: 1;
}

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

/* ---------------- Pagination bar (Customer Report / Human Review / SOP Management) ---------------- */
.pagination-bar {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  margin-top: 10px;
}

.pagination-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.pagination-info {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination-size-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-right: 6px;
}

.pagination-size-label select {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

.pagination-nav-btn,
.pagination-page-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 12px;
  font-weight: 600;
}

.pagination-nav-btn:hover:not(:disabled),
.pagination-page-btn:hover:not(.is-active) {
  background: var(--color-bg);
}

.pagination-nav-btn:disabled {
  color: var(--color-text-muted);
  cursor: not-allowed;
  opacity: 0.5;
}

.pagination-page-btn.is-active {
  background: var(--color-sidebar);
  border-color: var(--color-sidebar);
  color: #ffffff;
}

.pagination-ellipsis {
  font-size: 12px;
  color: var(--color-text-muted);
  padding: 0 2px;
}

@media (max-width: 720px) {
  .pagination-bar-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------------- Placeholder page ---------------- */
.placeholder-box {
  max-width: 420px;
  margin: 60px auto 0 auto;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 28px;
  box-shadow: var(--shadow-card);
}

.placeholder-icon {
  font-size: 26px;
  margin-bottom: 10px;
}

.placeholder-box h2 {
  font-family: var(--font-display);
  font-size: 16px;
  margin: 0 0 8px 0;
}

.placeholder-box p {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; gap: 10px; }
}
