.ticket-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(360px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.ticket-list {
  display: grid;
  gap: 10px;
}

.ticket-row {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  text-align: left;
}

.ticket-row:hover,
.ticket-row.is-selected {
  border-color: rgba(40, 124, 91, 0.55);
  box-shadow: 0 8px 24px rgba(32, 35, 31, 0.08);
}

.ticket-row-top,
.ticket-row-meta,
.detail-title,
.status-editor,
.timeline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ticket-id {
  color: var(--muted);
  font-size: 12px;
}

.ticket-row h3,
.detail-title h3,
.device-card h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: 0;
}

.ticket-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.status {
  background: #e7eee6;
  color: var(--green-dark);
}

.badge.priority-紧急 {
  background: #fae7e4;
  color: var(--red);
}

.badge.priority-高 {
  background: #fff0d2;
  color: var(--amber);
}

.badge.priority-中 {
  background: #e2f2f4;
  color: var(--teal);
}

.badge.priority-低 {
  background: #ece9f7;
  color: var(--violet);
}

.ticket-detail {
  position: sticky;
  top: 18px;
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.detail-stack {
  display: grid;
  gap: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.field {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.field strong,
.field-value {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.field-value > strong {
  margin-top: 0;
}

.field-value a {
  color: var(--green-dark);
  font-weight: 800;
}

.ticket-media-field .chat-attachment-grid {
  margin-top: 8px;
}

.description-box {
  border-left: 3px solid var(--green);
  background: var(--surface-strong);
  padding: 12px 14px;
}

.description-box p {
  margin: 5px 0 0;
  line-height: 1.6;
}

.ticket-chat {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-head h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
  letter-spacing: 0;
}

.chat-message-list {
  display: grid;
  max-height: 360px;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.chat-state {
  display: grid;
  min-height: 88px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.chat-message {
  display: flex;
}

.chat-message.is-own {
  justify-content: flex-end;
}

.chat-bubble {
  width: min(100%, 440px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.chat-message.is-own .chat-bubble {
  border-color: rgba(37, 99, 235, 0.22);
  background: var(--primary-weak);
}

.chat-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chat-meta strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.chat-bubble p {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-translation {
  margin-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.34);
  padding-top: 8px;
}

.chat-original {
  margin-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.34);
  padding-top: 8px;
}

.chat-translation span,
.chat-original summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.chat-original summary {
  cursor: pointer;
}

.chat-bubble .chat-translation p,
.chat-bubble .chat-original p {
  margin-top: 4px;
  color: #465568;
}

.chat-attachment-grid,
.message-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.message-image-button {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0;
  cursor: zoom-in;
}

.message-image-button img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.message-video-container,
.message-attachment-link {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.message-video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  object-fit: contain;
}

.message-attachment-link {
  display: grid;
  min-height: 96px;
  align-content: center;
  justify-items: center;
  gap: 5px;
  color: var(--ink);
  padding: 10px;
  text-align: center;
  text-decoration: none;
}

.message-attachment-icon svg,
.message-preview-file svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.message-attachment-name {
  font-size: 12px;
  font-weight: 800;
}

.message-attachment-action {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.message-composer {
  display: grid;
  gap: 10px;
}

.message-composer textarea {
  min-height: 92px;
}

.message-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.message-upload-row input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.message-file-button {
  cursor: pointer;
}

.message-file-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.message-preview-grid {
  margin-top: 0;
}

.message-preview-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.message-preview-media {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  background: #edf3f1;
  object-fit: cover;
}

.message-preview-file {
  display: grid;
  width: 100%;
  aspect-ratio: 1;
  align-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
}

.message-preview-file strong {
  color: var(--ink);
  font-size: 12px;
}

.message-preview-item .icon-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 30px;
  min-height: 30px;
  border-color: rgba(15, 23, 42, 0.16);
  background: rgba(255, 255, 255, 0.92);
  color: var(--danger);
}

.message-preview-item > span {
  display: block;
  overflow: hidden;
  padding: 6px 7px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-composer-actions {
  display: flex;
  justify-content: flex-end;
}

.status-editor {
  align-items: end;
}

.status-editor label {
  flex: 1;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  align-items: start;
  justify-content: flex-start;
}

.timeline-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--green);
}

.timeline-item p {
  margin: 2px 0 0;
  color: var(--muted);
}

.ticket-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

