.sup-widget { position: fixed; right: 20px; bottom: 20px; z-index: 180; }
.sup-bubble {
  width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--rust); color: #fff; font-size: 1.3rem;
  display: grid; place-items: center;
  box-shadow: 0 14px 34px -12px rgba(137,59,173,.85);
  transition: transform .2s var(--ease), background .2s;
}
.sup-bubble:hover { background: var(--rust-bright); transform: translateY(-2px) scale(1.04); }
.sup-bubble.open { transform: scale(.92); }

.sup-panel {
  position: absolute; right: 0; bottom: 70px;
  width: min(380px, calc(100vw - 40px)); height: min(560px, calc(100vh - 140px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.sup-panel[hidden] { display: none; }
.sup-panel-page {
  position: static; width: 100%; max-width: 820px; margin: 0 auto;
  height: min(640px, 72vh);
}

.sup-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.sup-title {
  flex: 1; font-family: 'Oswald', sans-serif; text-transform: uppercase;
  letter-spacing: 1px; font-size: 1rem; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sup-back, .sup-close {
  width: 30px; height: 30px; border-radius: var(--radius); flex: none;
  background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer;
  display: grid; place-items: center; transition: color .2s, background .2s;
}
.sup-back:hover, .sup-close:hover { color: var(--text); background: var(--surface-2); }
.sup-back[hidden] { display: none; }

.sup-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.sup-empty {
  margin: auto; text-align: center; color: var(--muted); padding: 30px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.sup-empty i { font-size: 1.8rem; color: var(--dim); }
.sup-empty p { font-size: .95rem; max-width: 34ch; line-height: 1.5; }
.sup-empty-sm { padding: 18px; }
.sup-loading { margin: auto; color: var(--muted); padding: 30px; }

.sup-list { display: flex; flex-direction: column; gap: 8px; padding: 12px; overflow-y: auto; }
.sup-new-btn { justify-content: center; }
.sup-ticket {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 12px 14px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); cursor: pointer; color: var(--text);
  transition: border-color .2s, background .2s;
}
.sup-ticket:hover { border-color: var(--steel); background: var(--surface-2); }
.sup-ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sup-ticket-subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sup-ticket-time { font-family: 'Barlow Condensed', sans-serif; font-size: .78rem; color: var(--dim); letter-spacing: .5px; }

.sup-tag {
  flex: none; padding: 2px 8px; border-radius: 999px;
  font-family: 'Barlow Condensed', sans-serif; text-transform: uppercase;
  letter-spacing: 1px; font-size: .66rem; font-weight: 700;
}
.sup-tag-open { background: rgba(80,200,120,.14); border: 1px solid #50c878; color: #9be7b4; }
.sup-tag-closed { background: rgba(141,138,131,.14); border: 1px solid var(--steel); color: var(--muted); }

.sup-new { display: flex; flex-direction: column; gap: 8px; padding: 14px; overflow-y: auto; }
.sup-new label {
  font-family: 'Barlow Condensed', sans-serif; text-transform: uppercase;
  letter-spacing: 1.5px; font-size: .76rem; color: var(--muted); margin-top: 4px;
}
.sup-new input, .sup-new textarea {
  width: 100%; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); font-family: 'Barlow', sans-serif;
  font-size: .98rem; resize: vertical;
}
.sup-new input:focus, .sup-new textarea:focus {
  outline: none; border-color: var(--rust); box-shadow: 0 0 0 3px rgba(137,59,173,.25);
}
.sup-new select {
  width: 100%; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); font-family: 'Barlow', sans-serif;
  font-size: .98rem; cursor: pointer;
}
.sup-new select:focus { outline: none; border-color: var(--rust); box-shadow: 0 0 0 3px rgba(137,59,173,.25); }
.sup-new > button { margin-top: 10px; justify-content: center; }
.sup-hint { font-size: .85rem; color: var(--muted); min-height: 1em; }

.sup-chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sup-thread {
  flex: 1; min-height: 0; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.sup-msg { display: flex; flex-direction: column; max-width: 82%; }
.sup-msg-other { align-self: flex-start; align-items: flex-start; }
.sup-msg-mine { align-self: flex-end; align-items: flex-end; }
.sup-bubble-msg {
  padding: 9px 13px; border-radius: 12px; font-size: .95rem; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--text);
}
.sup-msg-mine .sup-bubble-msg,
.sup-msg-staff .sup-bubble-msg { background: var(--rust); border-color: var(--rust); color: #fff; }
.sup-meta {
  margin-top: 4px; font-family: 'Barlow Condensed', sans-serif;
  font-size: .72rem; color: var(--dim); letter-spacing: .5px;
}

.sup-compose {
  display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg-2);
}
.sup-input {
  flex: 1; min-width: 0; resize: none; max-height: 120px; padding: 9px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); font-family: 'Barlow', sans-serif; font-size: .95rem; line-height: 1.4;
}
.sup-input:focus { outline: none; border-color: var(--rust); }
.sup-input:disabled { opacity: .6; }
.sup-send {
  width: 38px; height: 38px; flex: none; border: 0; border-radius: var(--radius);
  background: var(--rust); color: #fff; cursor: pointer; display: grid; place-items: center;
  transition: background .2s;
}
.sup-send:hover { background: var(--rust-bright); }
.sup-flash { width: 100%; padding: 6px 0 0; color: #ffb3b3; font-size: .85rem; text-align: center; }

.ticket-filter { display: flex; gap: 6px; }
.ticket-filter-btn {
  padding: 5px 12px; border-radius: var(--radius); cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  font-family: 'Barlow Condensed', sans-serif; text-transform: uppercase;
  letter-spacing: 1px; font-size: .76rem; font-weight: 600;
  transition: border-color .2s, color .2s;
}
.ticket-filter-btn.is-active { border-color: var(--rust); color: var(--text); }

.staff-tickets { display: grid; grid-template-columns: 300px 1fr; }
.staff-ticket-list {
  border-right: 1px solid var(--line); overflow-y: auto; max-height: 540px;
  display: flex; flex-direction: column;
}
.staff-ticket-item {
  display: flex; flex-direction: column; gap: 5px; text-align: left;
  padding: 13px 16px; background: none; border: 0; border-bottom: 1px solid var(--line);
  cursor: pointer; color: var(--text); transition: background .15s;
}
.staff-ticket-item:hover { background: var(--surface-2); }
.staff-ticket-item.is-active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--rust); }
.sti-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sti-subject { font-weight: 600; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sti-meta { font-family: 'Barlow Condensed', sans-serif; font-size: .78rem; color: var(--muted); letter-spacing: .5px; }

.staff-ticket-chat { display: flex; flex-direction: column; min-height: 360px; max-height: 540px; }
.staff-chat { height: 100%; }
.staff-chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.staff-chat-subject { font-weight: 600; }
.staff-chat-who { font-size: .82rem; color: var(--muted); }
.staff-chat-toggle { flex: none; }

@media (max-width: 760px) {
  .staff-tickets { grid-template-columns: 1fr; }
  .staff-ticket-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 240px; }
}

.tickets-app {
  display: flex; height: calc(100vh - 72px); height: calc(100svh - 72px); margin-top: 72px;
}
.tickets-sidebar {
  width: 340px; flex: none; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--bg-2); min-height: 0;
}
.tickets-sidebar-head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.tickets-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tickets-title {
  font-family: 'Oswald', sans-serif; text-transform: uppercase; letter-spacing: 1px;
  font-size: 1.3rem; color: var(--text); display: flex; align-items: center; gap: 10px;
}
.tickets-sidebar .staff-ticket-list { flex: 1; min-height: 0; max-height: none; border-right: 0; }
.tickets-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.tickets-main > .sup-chat, .tickets-main > .sup-empty { flex: 1; min-height: 0; }
.tickets-main .staff-chat { max-height: none; }

.staff-chat-player {
  display: flex; align-items: center; gap: 12px; min-width: 0;
  background: none; border: 0; cursor: pointer; color: var(--text); text-align: left;
  padding: 4px 6px; border-radius: var(--radius); transition: background .15s;
}
.staff-chat-player:hover { background: var(--surface-2); }
.sc-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--rust); color: #fff;
  font-family: 'Oswald', sans-serif; font-weight: 700; font-size: 1rem; text-transform: uppercase;
}
.sc-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sc-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sc-name { font-weight: 600; }
.sc-roles { display: flex; flex-wrap: wrap; gap: 5px; }
.staff-chat-actions { display: flex; align-items: center; gap: 10px; flex: none; }

.sup-seen {
  padding: 0 16px 6px; text-align: right; text-transform: uppercase;
  font-family: 'Barlow Condensed', sans-serif; font-size: .74rem; letter-spacing: .5px; color: var(--dim);
}
.sup-seen[hidden] { display: none; }

.sup-typing {
  display: flex; align-items: center; gap: 10px; padding: 4px 16px 8px;
  color: var(--muted); font-family: 'Barlow Condensed', sans-serif; font-size: .82rem; letter-spacing: .5px;
}
.sup-typing[hidden] { display: none; }
.sup-typing-dots { display: inline-flex; gap: 3px; }
.sup-typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: supTyping 1.2s infinite ease-in-out; }
.sup-typing-dots i:nth-child(2) { animation-delay: .15s; }
.sup-typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes supTyping {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@media (max-width: 860px) {
  .tickets-app { flex-direction: column; height: auto; min-height: calc(100vh - 72px); }
  .tickets-sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .tickets-sidebar .staff-ticket-list { max-height: 38vh; }
  .tickets-main { min-height: 60vh; }
}
