/* Human-support ticket desk */
body.ticket-page {
  min-height: 100vh;
  background:
    radial-gradient(800px 440px at 95% 0%, rgba(200,243,110,.18), transparent 66%),
    linear-gradient(180deg, #f6f4ed, #f1eee5);
  overflow-x: hidden;
}
body.ticket-page::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(18,36,29,.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(18,36,29,.026) 1px, transparent 1px);
  background-size: 76px 76px;
  mask-image: linear-gradient(to bottom, black, transparent 55%);
}
.ticket-page .toast { z-index: 500; }

.desk-head {
  position: sticky; top: 0; z-index: 40;
  min-height: 70px; padding: 12px clamp(18px, 3vw, 40px);
  display: flex; align-items: center; gap: 24px;
  background: rgba(246,244,237,.86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.desk-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.desk-nav a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 11px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 650;
  transition: background .18s ease, color .18s ease;
}
.desk-nav a:hover { color: var(--ink); background: rgba(255,255,255,.62); }
.desk-nav a.is-active { color: var(--green); background: var(--lime-soft); }
.desk-nav a svg { width: 14px; height: 14px; opacity: .7; }
.desk-nav a.is-active svg { opacity: 1; }
.desk-head > .pill { margin-left: 6px; }

.desk-main {
  position: relative; z-index: 1;
  width: min(calc(100% - clamp(28px, 5vw, 72px)), 1500px);
  margin: 0 auto; padding: 38px 0 24px;
}
.desk-intro { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 46px; align-items: end; }
.desk-intro h1 {
  margin-top: 13px;
  font-family: var(--font-display); font-size: clamp(3rem, 4.6vw, 4.6rem);
  font-weight: 400; line-height: .96; letter-spacing: -.055em;
}
.desk-lede { margin-top: 15px; max-width: 620px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.desk-stats { display: flex; align-items: stretch; }
.desk-stats > div {
  min-width: 116px; padding: 2px 18px;
  display: flex; flex-direction: column; border-left: 1px solid var(--line);
}
.desk-stats > div:first-child { border-left: 0; padding-left: 0; }
.desk-stats > div:last-child { padding-right: 0; }
.desk-stats span { color: var(--muted); font-size: 8px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.desk-stats strong { margin-top: 5px; font-size: 29px; line-height: 1; letter-spacing: -.05em; font-weight: 750; }
.desk-stats small { margin-top: 4px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.desk-stats > div:first-child strong { color: #9a5a1e; }
.desk-stats > div:nth-child(2) strong { color: #256b87; }
.desk-stats > div:nth-child(3) strong { color: var(--green-2); }

.desk-grid {
  display: grid; grid-template-columns: minmax(340px, .82fr) minmax(0, 1.18fr);
  gap: 20px; align-items: start; margin-top: 32px;
}
.queue-panel, .detail-panel {
  background: rgba(255,253,248,.9);
  border: 1px solid rgba(18,36,29,.11);
  border-radius: 23px;
  box-shadow: 0 24px 54px -46px rgba(11,58,45,.32);
  min-width: 0;
}
.queue-panel { overflow: hidden; }
.queue-head { padding: 20px 20px 13px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.queue-head h2 { font-size: 17px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.queue-head p { margin-top: 4px; color: var(--muted); font-size: 9.5px; }
.queue-head .icon-btn { width: 34px; height: 34px; }
.queue-tools { display: grid; grid-template-columns: 1fr 138px; gap: 8px; padding: 0 20px 12px; }
.desk-search {
  display: flex; align-items: center; gap: 8px;
  min-height: 38px; padding: 0 11px; border-radius: 10px;
  background: #f3f0e7; border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.desk-search:focus-within { background: var(--white); border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(20,88,68,.08); }
.desk-search svg { width: 14px; height: 14px; color: var(--muted); flex: 0 0 auto; }
.desk-search input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 10.5px; }
.desk-search input::placeholder { color: #5f6d66; }
.desk-filter select {
  width: 100%; height: 38px; padding: 0 28px 0 10px; appearance: none;
  border: 1px solid transparent; border-radius: 10px; background-color: #f3f0e7;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%236c7b74' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
  color: var(--ink-2); font-size: 10px; font-weight: 650; cursor: pointer; outline: 0;
}
.desk-filter select:focus { background-color: var(--white); border-color: var(--green-2); }
.queue-list {
  max-height: 592px; overflow-y: auto; padding: 0 8px 8px;
  scrollbar-width: thin; scrollbar-color: rgba(11,58,45,.14) transparent;
}
.queue-list::-webkit-scrollbar { width: 7px; }
.queue-list::-webkit-scrollbar-thumb { background: rgba(11,58,45,.13); border-radius: 99px; }
.ticket-row {
  width: 100%; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center;
  padding: 13px 12px; border-radius: 12px; background: transparent;
  text-align: left; color: var(--ink); border: 0; transition: background .16s ease, box-shadow .16s ease;
}
.ticket-row + .ticket-row { border-top: 1px solid rgba(18,36,29,.07); border-radius: 0; }
.ticket-row:hover, .ticket-row.is-active { background: rgba(200,243,110,.22); border-radius: 12px; border-top-color: transparent; }
.ticket-row.is-active { box-shadow: inset 3px 0 0 var(--green-2); }
.ticket-row-main { min-width: 0; }
.ticket-row-top { display: flex; align-items: center; gap: 7px; }
.ticket-id { flex: 0 0 auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--green-2); font-size: 8.5px; font-weight: 750; letter-spacing: .04em; }
.ticket-time { margin-left: auto; color: #5f6d66; font-size: 8px; }
.ticket-subject { margin-top: 5px; font-size: 11.5px; font-weight: 750; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-email { margin-top: 4px; color: var(--muted); font-size: 8.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.ticket-status {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  padding: 4px 7px; border-radius: 999px; font-size: 8px; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase;
}
.ticket-status::before { content: ""; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.ticket-status--open { color: #9a5a1e; background: #f8ead6; }
.ticket-status--in_progress { color: #256b87; background: #e2eff4; }
.ticket-status--resolved { color: var(--green-2); background: #e4f0e5; }
.queue-foot {
  padding: 11px 20px 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 8.5px;
}
.queue-foot > span:first-child { display: flex; align-items: center; gap: 6px; }
.queue-foot .status-dot { width: 5px; height: 5px; box-shadow: none; }
.queue-empty { padding: 54px 24px; text-align: center; }
.queue-empty .empty-icon { width: 50px; height: 50px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 15px; background: var(--lime-soft); color: var(--green-2); }
.queue-empty .empty-icon svg { width: 24px; height: 24px; }
.queue-empty h3 { font-family: var(--font-display); font-size: 22px; font-weight: 400; letter-spacing: -.025em; }
.queue-empty p { margin-top: 5px; color: var(--muted); font-size: 10.5px; }
.queue-skeleton { height: 74px; margin: 7px 8px; border-radius: 12px; background: linear-gradient(100deg, #f4f1e9 30%, #fbf9f4 50%, #f4f1e9 70%); background-size: 200% 100%; animation: desk-shimmer 1.4s infinite linear; }
@keyframes desk-shimmer { to { background-position: -200% 0; } }

.detail-panel { position: sticky; top: 88px; min-height: 620px; padding: 24px; }
.detail-empty { min-height: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px; }
.detail-empty-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: var(--lime-soft); color: var(--green-2); }
.detail-empty-icon svg { width: 30px; height: 30px; }
.detail-empty h2 { margin-top: 18px; font-family: var(--font-display); font-size: 29px; font-weight: 400; letter-spacing: -.03em; }
.detail-empty p { margin-top: 8px; max-width: 330px; color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.detail-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.detail-kicker { color: var(--green-2); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9.5px; font-weight: 750; letter-spacing: .05em; }
.detail-head h2 { margin-top: 5px; font-family: var(--font-display); font-size: 28px; font-weight: 400; line-height: 1.08; letter-spacing: -.03em; }
.detail-meta-line { margin-top: 6px; color: var(--muted); font-size: 8.5px; }
.detail-sep { margin: 0 5px; opacity: .5; }
.detail-head .ticket-status { margin-top: 3px; font-size: 8.5px; padding: 5px 8px; }
.detail-contact { display: flex; align-items: center; gap: 10px; margin-top: 15px; padding: 11px; border-radius: 12px; background: #f5f2e9; border: 1px solid rgba(18,36,29,.07); }
.contact-avatar { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--white); color: var(--green-2); box-shadow: inset 0 0 0 1px var(--line); }
.contact-avatar svg { width: 15px; height: 15px; }
.contact-label { display: block; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.detail-contact a#detail-email { display: inline-block; margin-top: 2px; color: var(--ink); font-size: 11px; font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.detail-contact a#detail-email:hover { color: var(--green-2); text-decoration: underline; }
.detail-mail { margin-left: auto; flex: 0 0 auto; min-height: 34px; font-size: 9.5px; }
.detail-mail svg { width: 13px; height: 13px; }
.detail-controls { display: flex; align-items: center; gap: 9px; margin-top: 14px; }
.detail-controls label { color: var(--muted); font-size: 8.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.detail-controls select {
  height: 32px; padding: 0 26px 0 9px; appearance: none; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background-color: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%236c7b74' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
  color: var(--ink-2); font-size: 9.5px; font-weight: 650; outline: 0;
}
.detail-controls select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(20,88,68,.08); }
.detail-updated { margin-left: auto; color: var(--muted); font-size: 8px; }
.section-label { color: var(--muted); font-size: 8px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.transcript-section { margin-top: 18px; }
.transcript { margin-top: 8px; display: flex; flex-direction: column; gap: 9px; max-height: 228px; overflow-y: auto; padding-right: 3px; scrollbar-width: thin; scrollbar-color: rgba(11,58,45,.13) transparent; }
.transcript::-webkit-scrollbar { width: 6px; }
.transcript::-webkit-scrollbar-thumb { background: rgba(11,58,45,.13); border-radius: 99px; }
.transcript-line { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; max-width: 90%; }
.transcript-line.is-user { align-self: flex-end; align-items: flex-end; }
.transcript-role { color: var(--muted); font-size: 7.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.transcript-bubble { padding: 8px 10px; border-radius: 3px 10px 10px 10px; background: #f5f2e9; color: var(--ink-2); font-size: 10px; line-height: 1.5; white-space: pre-wrap; }
.transcript-line.is-user .transcript-bubble { background: var(--green); color: rgba(255,255,255,.92); border-radius: 10px 3px 10px 10px; }
.note-section { margin-top: 18px; }
.note-section label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 8px; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.note-section textarea {
  width: 100%; min-height: 90px; resize: vertical; padding: 10px 11px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbf9f4;
  color: var(--ink); font-size: 10.5px; line-height: 1.55; outline: 0;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.note-section textarea:focus { background: var(--white); border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(20,88,68,.08); }
.note-section textarea::placeholder { color: #5f6d66; }
.detail-actions { display: flex; gap: 9px; margin-top: 14px; flex-wrap: wrap; }
.detail-actions .btn { min-height: 38px; font-size: 10.5px; padding: 8px 13px; }
.detail-actions .btn svg { width: 13px; height: 13px; }
.detail-delete { color: #983f2c; margin-left: auto; }
.detail-delete:hover { background: #fae9e4; box-shadow: inset 0 0 0 1px #983f2c; }
.detail-delete.is-armed { background: #983f2c; color: var(--white); box-shadow: none; }
.detail-error { margin-top: 8px; color: #983f2c; font-size: 9.5px; }
.detail-error:empty { display: none; }

.desk-foot { margin-top: 28px; padding-top: 15px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; color: var(--muted); font-size: 8.5px; }
.desk-foot a { color: var(--ink-2); text-decoration: none; font-weight: 700; }
.desk-foot a:hover { text-decoration: underline; }

@media (max-width: 1180px) {
  .desk-intro { grid-template-columns: 1fr; gap: 24px; }
  .desk-stats { align-self: start; }
  .desk-grid { grid-template-columns: minmax(310px, .8fr) minmax(0, 1.2fr); }
  .desk-stats > div { min-width: 104px; padding: 2px 14px; }
}
@media (max-width: 950px) {
  .desk-grid { grid-template-columns: 1fr; }
  .detail-panel { position: relative; top: auto; min-height: 0; }
  .queue-list { max-height: 470px; }
  .desk-head { flex-wrap: wrap; gap: 10px 18px; }
  .desk-nav { margin-left: auto; }
  .desk-head > .pill { display: none; }
}
@media (max-width: 700px) {
  .desk-main { width: calc(100% - 28px); padding-top: 26px; }
  .desk-intro h1 { font-size: clamp(2.8rem, 11vw, 3.8rem); }
  .desk-lede { font-size: 12px; }
  .desk-stats { flex-wrap: wrap; gap: 14px 0; width: 100%; }
  .desk-stats > div { flex: 1 1 45%; border-left: 0; padding: 0; }
  .desk-stats > div:nth-child(2), .desk-stats > div:nth-child(4) { border-left: 1px solid var(--line); padding-left: 12px; }
  .desk-stats strong { font-size: 25px; }
  .queue-panel, .detail-panel { border-radius: 19px; }
  .detail-panel { padding: 19px 16px; }
  .detail-empty { min-height: 360px; padding: 24px; }
  .detail-head h2 { font-size: 24px; }
  .detail-contact { flex-wrap: wrap; }
  .detail-mail { margin-left: 0; }
  .desk-foot { flex-direction: column; gap: 8px; }
}
@media (max-width: 460px) {
  .desk-head { padding: 10px 13px; }
  .desk-nav a { padding: 8px 8px; font-size: 9.5px; }
  .desk-nav a svg { width: 12px; height: 12px; }
  .desk-main { width: calc(100% - 24px); }
  .queue-tools { grid-template-columns: 1fr; padding: 0 14px 12px; }
  .queue-head { padding-left: 14px; padding-right: 14px; }
  .queue-list { max-height: 440px; }
  .queue-foot { padding-left: 14px; padding-right: 14px; }
  .ticket-row { padding-left: 9px; padding-right: 9px; }
  .ticket-row-side { display: none; }
  .detail-contact, .detail-actions { flex-direction: column; align-items: stretch; }
  .detail-mail { justify-content: center; }
  .detail-delete { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
