:root,
:root[data-theme="dark"] {
  --bg: #0e0e12;
  --panel: #17171c;
  --panel-border: #2a2a32;
  --chip-bg: #202027;
  --chip-bg-hover: #292930;
  --text: #f2f2f5;
  --text-muted: #8b8b96;
  --accent: #2dd4bf;
  --accent-2: #4ade80;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --ok-bg: rgba(74, 222, 128, 0.12);
  --ok: #4ade80;
  --radius: 16px;
}

:root[data-theme="light"] {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-border: #e5e7eb;
  --chip-bg: #eef0f3;
  --chip-bg-hover: #e3e6ea;
  --text: #16171a;
  --text-muted: #6b6f76;
  --accent: #0d9488;
  --accent-2: #16a34a;
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.1);
  --ok-bg: rgba(22, 163, 74, 0.1);
  --ok: #16a34a;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar,
.panel,
.stat-card,
.agent-panel,
.chip-select,
.search-input,
.updated-pill,
.icon-btn,
.count-pill,
th,
td {
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.status-dot {
  transition: background 0.25s ease, box-shadow 0.25s ease;
}


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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark-crop {
  width: 29px;
  height: 28px;
  overflow: hidden;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
}

.brand-mark-crop img {
  position: absolute;
  top: 0;
  left: 0;
  height: 28px;
  width: auto;
  max-width: none;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.brand-suffix {
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
  font-size: 13px;
  vertical-align: middle;
}

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

.updated-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px var(--ok-bg);
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--chip-bg);
  border: none;
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: var(--chip-bg-hover);
  color: var(--text);
}

.icon-btn.is-spinning svg {
  animation: spin 0.6s linear;
}

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


.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.dashboard-top {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  align-items: start;
}

@media (max-width: 980px) {
  .dashboard-top {
    grid-template-columns: 1fr;
  }
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-eyebrow {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

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

.section-hints {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hint-pill {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--chip-bg);
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.hint-pill:empty {
  display: none;
}

.is-hidden {
  display: none !important;
}

.table-wrap--capped {
  max-height: 340px;
  overflow-y: auto;
}


.filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-row-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 4px;
}

.chip-select {
  background: var(--chip-bg);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  appearance: none;
}

.chip-select:hover {
  background: var(--chip-bg-hover);
}

.chip-select:focus {
  outline: 1px solid var(--accent);
}


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

.stats-grid--single {
  grid-template-columns: minmax(220px, 320px);
}

.stats-grid--groups {
  grid-template-columns: repeat(2, minmax(200px, 320px));
}


.priority-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--danger-bg);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 14px;
  overflow: hidden;
  max-height: 60px;
  opacity: 1;
  transition: opacity 0.2s ease, max-height 0.25s ease, padding 0.25s ease;
}

.priority-banner.is-collapsed {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  pointer-events: none;
}

.priority-banner-icon {
  font-size: 16px;
}

.priority-banner-label {
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.priority-banner-text {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 132px;
  justify-content: center;
}

.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--ok-bg);
  color: var(--accent-2);
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-card--alert .stat-icon {
  background: var(--danger-bg);
  color: var(--danger);
}

.stat-card--alert .stat-value {
  color: var(--danger);
}

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

.stat-value {
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-value.is-updated {
  animation: value-pulse 0.4s ease;
}

.stat-value-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.sparkline {
  width: 90px;
  height: 32px;
  color: var(--accent);
  flex-shrink: 0;
  overflow: visible;
}

.percent-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.percent-badge.is-bad {
  color: var(--danger);
  background: var(--danger-bg);
}

.percent-badge.is-good {
  color: var(--ok);
  background: var(--ok-bg);
}

@keyframes value-pulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.12);
    color: var(--accent);
  }
  100% {
    transform: scale(1);
  }
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.trend-icon {
  width: 14px;
  height: 14px;
}

.trend:not(:empty) {
  animation: row-fade-in 0.3s ease;
}

.trend-up {
  color: var(--ok);
}

.trend-down {
  color: var(--danger);
}

.stat-card.is-loading .stat-label,
.stat-card.is-loading .stat-value {
  color: transparent;
  background: linear-gradient(90deg, #26262e 25%, #313139 37%, #26262e 63%);
  background-size: 400% 100%;
  border-radius: 6px;
  animation: skeleton-pulse 1.4s ease infinite;
}

.stat-card.is-loading .stat-label {
  width: 60%;
  height: 13px;
}

.stat-card.is-loading .stat-value {
  width: 45%;
  height: 34px;
}

@keyframes skeleton-pulse {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}


.agent-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 22px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  opacity: 1;
  max-height: 600px;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.25s ease, padding 0.25s ease, margin 0.25s ease,
    border-color 0.25s ease;
}

.agent-panel.is-collapsed {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  pointer-events: none;
}

.agent-panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.agent-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0e0e12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  object-fit: cover;
}

.agent-panel-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.agent-panel-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.agent-panel-subtitle strong {
  color: var(--text);
}

.agent-recent-chats {
  border-top: 1px solid var(--panel-border);
  padding-top: 14px;
}

.agent-recent-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.agent-recent-chats ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-recent-chats li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--panel-border);
}

.agent-recent-chats li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.chat-contact {
  font-weight: 600;
  white-space: nowrap;
}

.chat-message {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-inline {
  color: var(--text-muted);
  font-size: 13px;
}


.ignored-panel {
  border-bottom: 1px solid var(--panel-border);
  padding: 18px 26px;
  opacity: 1;
  max-height: 400px;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.25s ease, padding 0.25s ease, border-color 0.25s ease;
}

.ignored-panel.is-collapsed {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  pointer-events: none;
}

.ignored-panel ul {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ignored-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.team-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.team-form .search-input {
  min-width: 160px;
  flex: 1;
}

.restore-btn {
  background: var(--chip-bg);
  color: var(--text-muted);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}

.restore-btn:hover {
  background: var(--chip-bg-hover);
  color: var(--text);
}


.ignore-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.ignore-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.ignore-btn svg {
  width: 14px;
  height: 14px;
}

.resolve-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--chip-bg);
  color: var(--text-muted);
  border: none;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.resolve-btn:hover {
  background: var(--ok-bg);
  color: var(--ok);
}

.resolve-btn svg {
  width: 14px;
  height: 14px;
}

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

.ignore-group-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.ignore-group-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.ignore-group-btn svg {
  width: 14px;
  height: 14px;
}


.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  padding: 22px 26px;
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-header h2 {
  margin: 0 0 2px;
  font-size: 16px;
}

.panel-subtitle {
  color: var(--text-muted);
  font-size: 13px;
}

.panel-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--chip-bg);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.panel-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-input {
  background: var(--chip-bg);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: inherit;
  min-width: 220px;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  outline: 1px solid var(--accent);
}


.team-row {
  cursor: pointer;
  transition: background 0.12s ease;
}

.team-row:hover {
  background: var(--chip-bg);
}

.team-row.is-selected {
  background: var(--ok-bg);
}

.team-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.team-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0e0e12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
  object-fit: cover;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--chip-bg);
  color: var(--text-muted);
}

.count-pill.count-pill--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 12px 26px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--panel-border);
}

td {
  padding: 14px 26px;
  border-bottom: 1px solid var(--panel-border);
  vertical-align: top;
}

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

tbody tr {
  animation: row-fade-in 0.25s ease;
}

@keyframes row-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge--danger {
  color: var(--danger);
  background: var(--danger-bg);
}

.badge--ok {
  color: var(--ok);
  background: var(--ok-bg);
}

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

.cell-message {
  color: var(--text-muted);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-waited {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  .agent-recent-chats li {
    flex-direction: column;
    gap: 2px;
  }

  .panel-header-right {
    width: 100%;
  }

  .search-input {
    flex: 1;
    min-width: 0;
  }
}
