:root {
  color-scheme: light;
  --bg: #eef2f7;
  --text: #18212f;
  --muted: #667085;
  --glass: rgba(255, 255, 255, 0.76);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(24, 33, 47, 0.09);
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 18px 44px rgba(31, 45, 66, 0.1);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.08), rgba(22, 163, 74, 0.06) 42%, rgba(255, 255, 255, 0) 68%),
    var(--bg);
}

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 0 clamp(16px, 4vw, 42px);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px) saturate(1.25);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand strong { font-size: 17px; letter-spacing: 0; white-space: nowrap; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: white;
  background: linear-gradient(135deg, var(--blue), #10893e);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.user-area { display: flex; align-items: center; gap: 8px; }

.user-chip {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  transition: background .18s, transform .18s, border-color .18s;
}
.icon-btn:hover { background: white; transform: translateY(-1px); border-color: rgba(37, 99, 235, .25); }

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  width: min(1560px, 100%);
  margin: 0 auto;
  padding: 18px clamp(14px, 3vw, 34px) 40px;
}

.glass-card {
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel { position: sticky; top: 76px; }
.form-panel .glass-card { padding: 20px; }

.panel-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.accent-bar { width: 6px; height: 40px; border-radius: 8px; background: linear-gradient(180deg, var(--blue), var(--green)); }
.panel-heading h1, .panel-heading p { margin: 0; }
.panel-heading h1 { font-size: 20px; }
.panel-heading p { color: var(--muted); font-size: 12px; }

.field-label { color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 15px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(238, 242, 247, .72);
}
.segment {
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  transition: background .18s, color .18s;
}
.segment.active { color: white; background: var(--blue); box-shadow: 0 6px 14px rgba(37, 99, 235, .16); }

.field { display: block; position: relative; margin-bottom: 15px; }
.field span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 12px; }

input[type="text"], textarea, select {
  width: 100%;
  border: 1px solid rgba(24, 33, 47, .12);
  border-radius: 8px;
  background: rgba(255, 255, 255, .82);
  padding: 11px 12px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
textarea { resize: vertical; min-height: 130px; line-height: 1.6; }
input:focus, textarea:focus, select:focus {
  border-color: rgba(37, 99, 235, .58);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.counter {
  position: absolute;
  right: 8px;
  bottom: 7px;
  color: #98a2b3;
  font-size: 11px;
  font-style: normal;
  pointer-events: none;
}

.primary-btn, .secondary-btn {
  width: 100%;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: linear-gradient(90deg, var(--blue), #4c86ff);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .18);
  transition: transform .18s, filter .18s;
}
.secondary-btn { width: auto; padding: 0 14px; background: #1f2937; }
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-1px); filter: brightness(.98); }

.form-message { min-height: 18px; margin-top: 10px; color: var(--red); font-size: 12px; white-space: pre-wrap; }

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  margin-bottom: 14px;
}
.list-head h2, .list-head p { margin: 0; }
.list-head h2 { font-size: 19px; }
.list-head p { color: var(--muted); margin-top: 4px; font-size: 12px; }

.switch-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
}
.switch-field input { position: absolute; opacity: 0; pointer-events: none; }
.switch-field span {
  width: 38px;
  height: 21px;
  border-radius: 8px;
  background: #cbd5e1;
  position: relative;
  transition: background .2s;
}
.switch-field span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: white;
  transition: transform .2s;
}
.switch-field input:checked + span { background: var(--blue); }
.switch-field input:checked + span::after { transform: translateX(17px); }

.filters { display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 15px; overflow-x: auto; padding-bottom: 3px; }
.filter-group { display: flex; gap: 8px; white-space: nowrap; }

.filter-chip, .status-chip {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .68);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .18s, color .18s, border-color .18s;
}
.filter-chip.active, .status-chip.active {
  color: white;
  border-color: transparent;
  background: var(--blue);
  box-shadow: 0 8px 16px rgba(37, 99, 235, .14);
}
.status-chip i { color: inherit; opacity: .72; font-style: normal; }

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

.ticket-card {
  padding: 16px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.ticket-card:hover { transform: translateY(-2px); box-shadow: 0 22px 48px rgba(31, 45, 66, .13); }

.ticket-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.ticket-title { margin: 0 0 10px; font-size: 17px; line-height: 1.35; }
.ticket-brief {
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 40px;
}

.reply-preview {
  min-height: 42px;
  margin: 12px 0 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 250, 252, .72);
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
}

.ticket-foot { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.continue-btn {
  border: 0;
  background: #eef2f7;
  color: #475467;
  height: 28px;
  padding: 0 10px;
  border-radius: 8px;
}

.status-badge, .type-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
}
.status-sent { color: #b45309; background: #fef3c7; }
.status-developing { color: #1d4ed8; background: #dbeafe; }
.status-failed { color: #b91c1c; background: #fee2e2; }
.status-completed { color: #15803d; background: #dcfce7; }
.status-closed { color: #475467; background: #e5e7eb; }
.type-issue { color: #0f766e; background: #ccfbf1; }
.type-feature { color: #1d4ed8; background: #dbeafe; }

.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 24, 40, .42);
  backdrop-filter: blur(6px);
}
.modal {
  width: min(880px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  padding: 22px;
}
.modal-head { display: flex; justify-content: space-between; gap: 16px; }
.modal-head h3 { margin: 10px 0 6px; font-size: 22px; line-height: 1.3; }
.badges { display: flex; gap: 8px; }
.detail-meta { color: var(--muted); font-size: 12px; }
.detail-description { white-space: pre-wrap; overflow-wrap: anywhere; }

.moderator-box {
  display: flex;
  align-items: end;
  gap: 10px;
  margin: 18px 0;
  padding: 14px;
  border: 1px dashed rgba(37, 99, 235, .3);
  border-radius: 8px;
  background: rgba(219, 234, 254, .38);
}
.moderator-box label { flex: 1; }
.moderator-box span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }

.reply-area h4 { margin: 18px 0 10px; font-size: 15px; }
.comment-list { display: grid; gap: 10px; margin-bottom: 14px; }
.comment { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.66); }
.comment-top { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.comment-author { color: var(--text); font-weight: 600; }
.private-tag { color: #b45309; background: #fef3c7; border-radius: 8px; padding: 1px 6px; }
.public-tag { color: #15803d; background: #dcfce7; border-radius: 8px; padding: 1px 6px; }
.comment-content { white-space: pre-wrap; overflow-wrap: anywhere; }

#commentForm textarea { min-height: 88px; margin-bottom: 10px; }
.reply-actions { display: flex; align-items: center; gap: 10px; }
.reply-actions button {
  margin-left: auto;
  width: auto;
  min-width: 74px;
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  color: white;
  background: var(--blue);
}
.check-option { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.privacy-hint { color: #98a2b3; font-size: 12px; }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.52);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(92vw, 480px);
  padding: 11px 16px;
  border-radius: 8px;
  color: white;
  background: #1f2937;
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s, visibility .2s, transform .2s;
}
.toast.show { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(-4px); }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .form-panel { position: static; }
  .ticket-grid { grid-template-columns: 1fr; }
  .filters { gap: 8px; }
}

@media (max-width: 560px) {
  body { font-size: 13px; }
  .topbar { padding: 0 14px; }
  .workspace { padding: 14px; }
  .brand strong { font-size: 16px; }
  .user-chip { max-width: 110px; }
  .list-head { align-items: flex-start; flex-direction: column; }
  .modal { padding: 16px; }
  .modal-head h3 { font-size: 19px; }
  .reply-actions { align-items: flex-start; flex-wrap: wrap; }
  .reply-actions button { margin-left: 0; width: 100%; }
}

.modal-mask[hidden] { display: none; }
