.tickets-main {
  min-height: calc(100dvh - 90px);
  padding: calc(var(--nav-height) + 54px) 0 86px;
}

.tickets-wrap {
  width: min(calc(100% - 32px), 1120px);
  max-width: 1120px;
  margin: 0 auto;
}

.tickets-heading {
  max-width: 720px;
  margin-bottom: 24px;
}

.tickets-heading h1 {
  margin: 8px 0 0;
  font-size: clamp(2.8rem, 5.5vw, 4.4rem);
  line-height: .96;
  letter-spacing: -.05em;
}

.tickets-heading p {
  max-width: 620px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.6;
}

.tickets-shell {
  display: grid;
  min-height: 680px;
  height: min(74vh, 760px);
  grid-template-columns: 292px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
}

.tickets-loading,
.tickets-gate {
  display: grid;
  min-height: 600px;
  grid-column: 1 / -1;
  place-items: center;
  padding: 34px;
  color: var(--muted);
  font-size: .84rem;
  text-align: center;
}

.tickets-gate-card {
  width: min(520px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg-raised);
}

.tickets-gate-card h2 {
  margin: 8px 0 0;
  font-size: 1.55rem;
  letter-spacing: -.035em;
}

.tickets-gate-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.6;
}

.tickets-gate-card .button-primary {
  margin-top: 20px;
}

.tickets-sidebar {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--bg-raised);
}

.tickets-sidebar-head {
  flex: 0 0 auto;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.tickets-new {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-green);
  border-radius: 10px;
  color: var(--green-2);
  background: rgba(130, 255, 79, .06);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 750;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease;
}

.tickets-new:hover,
.tickets-new:focus-visible {
  border-color: rgba(130, 255, 79, .45);
  color: #fff;
  background: rgba(130, 255, 79, .09);
  outline: none;
}

.tickets-account-line {
  margin: 12px 2px 0;
  color: var(--muted-2);
  font-size: .66rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.tickets-account-line strong {
  color: var(--text-soft);
  font-weight: 700;
}

.tickets-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  padding: 9px;
}

.ticket-list-empty {
  margin: auto 0;
  padding: 24px 16px;
  color: var(--muted-2);
  font-size: .72rem;
  line-height: 1.55;
  text-align: center;
}

.ticket-list-item {
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: border-color 130ms ease, background 130ms ease;
}

.ticket-list-item:hover {
  background: var(--surface-2);
}

.ticket-list-item.active {
  border-color: var(--line-green);
  background: rgba(130, 255, 79, .045);
}

.ticket-list-item.unread:not(.active) {
  border-color: var(--line);
}

.ticket-list-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ticket-list-id {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font: 700 .64rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.ticket-unread-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.ticket-list-subject {
  overflow: hidden;
  color: var(--text-soft);
  font-size: .76rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-list-item.unread .ticket-list-subject {
  color: var(--text);
}

.ticket-list-meta {
  color: var(--muted-2);
  font-size: .62rem;
  line-height: 1.45;
}

.ticket-status {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: .56rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ticket-status.open {
  border-color: var(--line-green);
  color: var(--green-2);
  background: rgba(130, 255, 79, .045);
}

.ticket-status.resolved {
  border-color: rgba(118, 190, 255, .2);
  color: #b8dbf4;
}

.tickets-content {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  background: var(--surface);
}

.ticket-empty-state {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.ticket-empty-state > div {
  max-width: 420px;
}

.ticket-empty-state strong {
  display: block;
  color: var(--text);
  font-size: 1.1rem;
  letter-spacing: -.02em;
}

.ticket-empty-state span {
  display: block;
  margin-top: 7px;
  color: var(--muted-2);
  font-size: .74rem;
  line-height: 1.55;
}

.ticket-create {
  width: min(100%, 720px);
  margin: 0 auto;
  padding: 36px 34px 40px;
}

.ticket-create-head h2 {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 1.8rem;
  letter-spacing: -.04em;
}

.ticket-create-head p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.55;
}

.ticket-handoff-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 18px;
  padding: 11px 12px;
  border: 1px solid var(--line-green);
  border-radius: 10px;
  background: rgba(130, 255, 79, .035);
}

.ticket-handoff-note strong {
  flex: 0 0 auto;
  color: var(--green-2);
  font-size: .66rem;
}

.ticket-handoff-note span {
  color: var(--muted);
  font-size: .66rem;
  line-height: 1.45;
}

.ticket-form {
  display: grid;
  gap: 17px;
  margin-top: 24px;
}

.ticket-field {
  display: grid;
  gap: 7px;
}

.ticket-field label {
  color: var(--muted);
  font-size: .62rem;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.ticket-field input,
.ticket-field select,
.ticket-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--bg-raised);
  outline: none;
  font: inherit;
  font-size: .78rem;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.ticket-field input,
.ticket-field select {
  min-height: 46px;
  padding: 0 13px;
}

.ticket-field textarea {
  min-height: 170px;
  padding: 13px;
  line-height: 1.55;
}

.ticket-field input:focus,
.ticket-field select:focus,
.ticket-field textarea:focus {
  border-color: rgba(130, 255, 79, .32);
  box-shadow: 0 0 0 3px rgba(130, 255, 79, .04);
}

.ticket-field small {
  color: var(--muted-2);
  font-size: .64rem;
  line-height: 1.5;
}

.ticket-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}

.ticket-form-error,
.ticket-inline-error {
  color: #ffaaaa;
  font-size: .7rem;
  line-height: 1.45;
}

.ticket-form-error {
  min-height: 18px;
}

.ticket-inline-error {
  padding: 8px 18px 0;
}

.ticket-inline-link {
  padding: 0;
  border: 0;
  color: var(--green-2);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ticket-thread {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.ticket-thread-head {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.ticket-thread-title {
  min-width: 0;
}

.ticket-thread-title .ticket-id {
  color: var(--muted-2);
  font: 700 .64rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.ticket-thread-title h2 {
  overflow: hidden;
  margin: 7px 0 0;
  color: var(--text);
  font-size: 1.12rem;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-thread-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.ticket-mini-button {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  cursor: pointer;
  font-size: .62rem;
  font-weight: 700;
}

.ticket-mini-button:hover,
.ticket-mini-button:focus-visible {
  border-color: var(--line-strong);
  color: var(--text);
  outline: none;
}

.ticket-mini-button.danger:hover,
.ticket-mini-button.danger:focus-visible {
  border-color: rgba(255, 120, 120, .24);
  color: #ffcaca;
}

.ticket-archive-note {
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted-2);
  background: var(--bg-raised);
  font-size: .66rem;
  line-height: 1.5;
}

.ticket-messages {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding: 22px;
  scroll-behavior: smooth;
}

.ticket-message {
  display: flex;
}

.ticket-message.user {
  justify-content: flex-end;
}

.ticket-message-inner {
  max-width: min(78%, 660px);
}

.ticket-message-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 3px 5px;
  color: var(--muted-2);
  font-size: .62rem;
}

.ticket-message.user .ticket-message-meta {
  justify-content: flex-end;
}

.ticket-message-meta strong {
  color: var(--muted);
  font-size: .64rem;
}

.ticket-bubble {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px 11px 11px 4px;
  color: var(--text-soft);
  background: var(--surface-2);
  font-size: .8rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ticket-message.user .ticket-bubble {
  border-color: var(--line-green);
  border-radius: 11px 11px 4px 11px;
  color: var(--text);
  background: rgba(130, 255, 79, .055);
}

.ticket-message-attachments {
  display: grid;
  gap: 6px;
  margin-top: 7px;
}

.ticket-message.user .ticket-message-attachments {
  justify-items: end;
}

.ticket-attachment-card {
  display: flex;
  width: min(320px, 100%);
  min-height: 48px;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text-soft);
  background: var(--bg-raised);
  text-decoration: none;
}

.ticket-attachment-card:hover {
  border-color: var(--line-strong);
}

.ticket-attachment-icon {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-green);
  border-radius: 8px;
  color: var(--green-2);
  background: rgba(130, 255, 79, .04);
  font-size: .54rem;
  font-weight: 800;
}

.ticket-attachment-card.image .ticket-attachment-icon {
  font-size: .9rem;
}

.ticket-attachment-card span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.ticket-attachment-card strong {
  overflow: hidden;
  color: var(--text-soft);
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-attachment-card small {
  color: var(--muted-2);
  font-size: .59rem;
}

.ticket-composer {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: var(--bg-raised);
}

.ticket-composer textarea {
  display: block;
  width: 100%;
  min-height: 86px;
  max-height: 180px;
  resize: vertical;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  font: inherit;
  font-size: .76rem;
  line-height: 1.55;
}

.ticket-composer textarea:focus {
  border-color: rgba(130, 255, 79, .3);
}

.ticket-composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
}

.ticket-composer-note {
  color: var(--muted-2);
  font-size: .63rem;
  line-height: 1.45;
}

.ticket-send {
  min-width: 106px;
  min-height: 39px;
  border: 1px solid var(--line-green);
  border-radius: 9px;
  color: #0a1308;
  background: var(--green);
  cursor: pointer;
  font-size: .68rem;
  font-weight: 800;
}

.ticket-send:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.ticket-attachment-picker {
  display: grid;
  gap: 7px;
}

.ticket-composer .ticket-attachment-picker {
  margin-top: 8px;
}

.ticket-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.ticket-attachment-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
}

.ticket-attachment-picker-row > span {
  color: var(--muted-2);
  font-size: .61rem;
}

.ticket-attach-button {
  display: inline-flex;
  min-height: 33px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-2);
  cursor: pointer;
  font-size: .63rem;
  font-weight: 700;
}

.ticket-attach-button:hover {
  border-color: var(--line-strong);
  color: var(--text);
}

.ticket-file-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ticket-file-chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 29px;
  align-items: center;
  gap: 6px;
  padding: 0 5px 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text-soft);
  background: var(--surface-2);
  font-size: .61rem;
}

.ticket-file-chip > span {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ticket-file-chip small {
  color: var(--muted-2);
  font-size: .56rem;
}

.ticket-file-chip button {
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.ticket-file-chip button:hover {
  color: #ffd0d0;
  background: rgba(255, 120, 120, .06);
}

@media (max-width: 820px) {
  .tickets-shell {
    height: auto;
    min-height: 700px;
    grid-template-columns: 1fr;
  }

  .tickets-sidebar {
    max-height: 280px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tickets-list {
    max-height: 180px;
  }

  .tickets-content {
    min-height: 540px;
  }

  .ticket-thread-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .ticket-thread-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  .tickets-main {
    padding: calc(var(--nav-height) + 42px) 0 60px;
  }

  .tickets-wrap {
    width: calc(100% - 20px);
  }

  .tickets-heading {
    margin-bottom: 20px;
  }

  .tickets-heading h1 {
    font-size: clamp(2.55rem, 14vw, 3.8rem);
  }

  .tickets-shell {
    border-radius: 14px;
  }

  .tickets-sidebar-head {
    padding: 14px;
  }

  .ticket-create {
    padding: 24px 16px 30px;
  }

  .ticket-handoff-note {
    flex-direction: column;
  }

  .ticket-thread-head,
  .ticket-messages {
    padding: 15px;
  }

  .ticket-thread-title h2 {
    white-space: normal;
  }

  .ticket-message-inner {
    max-width: 92%;
  }

  .ticket-composer {
    padding: 12px;
  }

  .ticket-composer-bottom,
  .ticket-attachment-picker-row {
    align-items: stretch;
    flex-direction: column;
  }

  .ticket-send,
  .ticket-attach-button {
    width: 100%;
    justify-content: center;
  }
}
