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

:root {
  --black: #1a1a1a;
  --white: #ffffff;
  --off-white: #f5f5f3;
  --light-grey: #e8e8e6;
  --mid-grey: #b0b0ad;
  --dark-grey: #6b6b68;
  --green: #2d8a4e;
  --yellow: #c49a1a;
  --red: #c43333;
  --green-bg: #edf7f0;
  --yellow-bg: #fdf6e3;
  --red-bg: #fdf0f0;
  --sales: #5b5fc7;
  --sales-bg: #eeeffe;
  --cs: #2d8a4e;
  --cs-bg: #edf7f0;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--off-white);
  color: var(--black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

/* ─── Setup screen ─── */
.setup-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 24px;
  gap: 24px;
}

.setup-logo {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1.5px solid var(--black);
  padding: 8px 16px;
  margin-bottom: 8px;
}

.setup-screen h1 {
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.setup-screen p {
  font-size: 16px;
  color: var(--dark-grey);
  text-align: center;
  max-width: 300px;
  line-height: 1.5;
}

.setup-screen button {
  width: 100%;
  max-width: 300px;
  padding: 16px;
  background: var(--black);
  color: var(--white);
  border: none;
  font-size: 15px;
  font-family: var(--font);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.2s;
  border-radius: 6px;
}

.setup-screen button:hover {
  opacity: 0.85;
}

.setup-error {
  color: var(--red);
  font-size: 15px;
}

.setup-loading {
  font-size: 15px;
  color: var(--dark-grey);
}

/* ─── Header ─── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--black);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

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

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

.status-dot.disconnected {
  background: var(--red);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.header-brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.header-title {
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

/* ─── Connection banner ─── */
.connection-banner {
  background: var(--yellow-bg);
  color: var(--yellow);
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  padding: 10px 20px;
  border-bottom: 1px solid #e8d9a8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.connection-banner.error {
  background: var(--red-bg);
  color: var(--red);
  border-bottom-color: #e8b8b8;
}

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

.connection-banner::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.connection-banner.error::before {
  content: "!";
  border: none;
  animation: none;
  font-weight: 700;
  font-size: 14px;
  width: auto;
  height: auto;
}

/* ─── Agent bar ─── */
.agent-bar {
  background: var(--white);
  border-bottom: 1px solid var(--light-grey);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--dark-grey);
}

.agent-bar-left strong {
  color: var(--black);
  font-weight: 600;
}

.agent-bar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ─── Department filter ─── */
.dept-filter {
  display: flex;
  background: var(--off-white);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.dept-filter-btn {
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mid-grey);
  background: none;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.dept-filter-btn:hover {
  color: var(--dark-grey);
}

.dept-filter-btn.active {
  background: var(--white);
  color: var(--black);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ─── Agents online panel ─── */
.agents-online {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agents-online-label {
  font-size: 12px;
  color: var(--mid-grey);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
  margin-right: 4px;
}

.agent-avatars {
  display: flex;
  align-items: center;
}

.agent-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--black);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--white);
  margin-left: -6px;
  position: relative;
  cursor: default;
  text-transform: uppercase;
}

.agent-avatar:first-child {
  margin-left: 0;
}

.agent-avatar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--white);
}

.agent-avatar[title]:hover {
  z-index: 2;
  transform: scale(1.1);
  transition: transform 0.15s;
}

/* ─── Queue section ─── */
.queue-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.queue-header {
  padding: 18px 24px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.queue-header-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--mid-grey);
}

.queue-header-count {
  font-size: 13px;
  color: var(--mid-grey);
}

/* ─── Queue list ─── */
.queue-list {
  flex: 1;
  padding: 8px 16px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--mid-grey);
  gap: 16px;
  padding: 80px 24px;
}

.empty-state .icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--light-grey);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.empty-state p {
  font-size: 18px;
  font-weight: 500;
  color: var(--dark-grey);
}

.empty-state .subtext {
  font-size: 15px;
  font-weight: 400;
  color: var(--mid-grey);
  margin-top: -8px;
}

/* ─── Chat card ─── */
.chat-card {
  background: var(--white);
  padding: 18px 20px;
  transition: all 0.15s ease;
  border: 1px solid var(--light-grey);
  position: relative;
  cursor: pointer;
}

.chat-card:hover {
  background: #fafaf8;
}

.chat-card:first-child {
  border-radius: 10px 10px 0 0;
}

.chat-card:last-of-type {
  border-radius: 0 0 10px 10px;
}

.chat-card:only-of-type {
  border-radius: 10px;
}

.chat-card + .chat-card {
  border-top: none;
}

.chat-card.warning {
  border-left: 3px solid var(--yellow);
}

.chat-card.urgent {
  border-left: 3px solid var(--red);
  background: var(--red-bg);
}

.chat-card.urgent:hover {
  background: #fbe8e8;
}

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

.chat-card-name {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  margin-right: 16px;
  letter-spacing: -0.01em;
}

.chat-card-time {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  padding: 3px 10px;
  border-radius: 4px;
}

.chat-card-time.green { color: var(--green); background: var(--green-bg); }
.chat-card-time.yellow { color: var(--yellow); background: var(--yellow-bg); }
.chat-card-time.red { color: var(--red); background: var(--red-bg); }

.chat-card-subject {
  font-size: 15px;
  color: var(--dark-grey);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 12px;
  line-height: 1.5;
}

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

.chat-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ─── Department badge (color-coded) ─── */
.chat-card-department {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chat-card-department::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.chat-card-department.dept-sales {
  color: var(--sales);
  background: var(--sales-bg);
}

.chat-card-department.dept-sales::before {
  background: var(--sales);
}

.chat-card-department.dept-cs {
  color: var(--cs);
  background: var(--cs-bg);
}

.chat-card-department.dept-cs::before {
  background: var(--cs);
}

.chat-card-channel {
  font-size: 13px;
  color: var(--mid-grey);
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-card-channel::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--mid-grey);
}

.claim-btn {
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--white);
  background: var(--black);
  border: none;
  padding: 8px 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.claim-btn:hover {
  opacity: 0.8;
}

.claim-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.claim-btn.claimed {
  background: var(--green);
  pointer-events: none;
}

/* ─── Footer ─── */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--white);
  border-top: 1px solid var(--light-grey);
}

footer button {
  background: none;
  border: none;
  font-size: 14px;
  font-family: var(--font);
  color: var(--dark-grey);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s;
  letter-spacing: 0.02em;
}

footer button:hover {
  background: var(--off-white);
  color: var(--black);
}

footer button.active {
  color: var(--black);
}

footer button.snoozed {
  color: var(--yellow);
}

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.modal-option {
  width: 100%;
  padding: 14px;
  background: var(--off-white);
  border: 1px solid var(--light-grey);
  border-radius: 8px;
  font-size: 15px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--black);
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}

.modal-option:hover {
  background: var(--light-grey);
}

.modal-cancel {
  width: 100%;
  padding: 14px;
  background: none;
  border: none;
  font-size: 15px;
  font-family: var(--font);
  color: var(--dark-grey);
  cursor: pointer;
  margin-top: 4px;
}

.modal-cancel:hover {
  color: var(--black);
}

/* ─── Support footer ─── */
.support-footer {
  text-align: center;
  padding: 10px 24px;
  font-size: 12px;
  color: var(--mid-grey);
  background: var(--off-white);
}

.support-footer a {
  color: var(--dark-grey);
  text-decoration: none;
  font-weight: 500;
}

.support-footer a:hover {
  text-decoration: underline;
  color: var(--black);
}

/* ─── Hidden utility ─── */
.hidden {
  display: none !important;
}

/* ─── Animations ─── */
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-card {
  animation: slideIn 0.2s ease-out;
}

@keyframes fadeOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.98); }
}

.chat-card.removing {
  animation: fadeOut 0.25s ease-out forwards;
}

/* ─── Responsive ─── */
@media (max-width: 480px) {
  .queue-list { padding: 8px 12px 12px; }
  .chat-card { padding: 16px 16px; }
  header { padding: 16px 16px; }
  .agent-bar { padding: 12px 16px; }
  .queue-header { padding: 14px 16px 8px; }
  .agents-online-label { display: none; }
}
