:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e3e6ea;
  --text: #24292f;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 8px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
.hidden { display: none !important; }
.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
.topbar nav a.active, .topbar nav a:hover { color: var(--primary); background: #eff4ff; }
.topbar .who { color: var(--muted); white-space: nowrap; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 16px 0 8px; font-size: 14px; }

button, .btn {
  font: inherit;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { border-color: #c4ccd6; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.danger { color: var(--danger); border-color: #f3c2c2; }
button.small { padding: 2px 8px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}
textarea { resize: vertical; min-height: 72px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd4fe; border-color: var(--primary); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; color: var(--muted); margin-bottom: 4px; font-size: 13px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; }
.spacer { flex: 1; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.list th { color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover { background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  color: var(--muted);
  white-space: nowrap;
}
.badge.st-pending_confirm { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.badge.st-pending { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.badge.st-in_progress { background: #dbeafe; border-color: #93c5fd; color: #1e40af; }
.badge.st-fix_pending_deploy { background: #ede9fe; border-color: #c4b5fd; color: #5b21b6; }
.badge.st-pending_retest { background: #cffafe; border-color: #67e8f9; color: #155e75; }
.badge.st-closed { background: #dcfce7; border-color: #86efac; color: #166534; }
.badge.st-needs_info { background: #ffedd5; border-color: #fdba74; color: #9a3412; }
.badge.st-duplicate, .badge.st-deferred { background: #f3f4f6; color: #4b5563; }
.badge.pri-high { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.badge.pri-medium { background: #fef9c3; border-color: #fde047; color: #854d0e; }
.badge.pri-low { background: #f3f4f6; color: #4b5563; }
.badge.res-pass { background: #dcfce7; border-color: #86efac; color: #166534; }
.badge.res-fail { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.badge.res-blocked { background: #ffedd5; border-color: #fdba74; color: #9a3412; }

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.big-number { font-size: 34px; font-weight: 700; color: var(--primary); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.issue-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 860px) {
  .grid2, .issue-layout { grid-template-columns: 1fr; }
}

.meta-row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.meta-row .k { color: var(--muted); white-space: nowrap; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--border); position: relative; }
.timeline li::before {
  content: '';
  position: absolute;
  left: -5px; top: 16px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #c4ccd6;
}
.timeline li.kind-fix::before { background: var(--primary); }
.timeline li.kind-comment::before { background: var(--ok); }
.timeline .ev-head { font-size: 13px; color: var(--muted); margin-bottom: 2px; }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kanban .col { min-width: 220px; flex: 1; background: #eceef1; border-radius: var(--radius); padding: 10px; }
.kanban .col h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.kanban .ticket {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  cursor: pointer;
}
.kanban .ticket:hover { border-color: var(--primary); }
.kanban .ticket .code { font-size: 12px; color: var(--muted); }

.attachments img, .att-img {
  max-width: 220px;
  max-height: 160px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 4px 8px 4px 0;
  vertical-align: top;
  cursor: zoom-in;
}

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: var(--card);
  border-radius: 10px;
  padding: 20px 22px;
  width: 640px;
  max-width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,.18);
}
.modal h3 { margin-top: 0; }
.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff;
  padding: 8px 18px; border-radius: 999px;
  z-index: 200; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
}
.toast.err { background: var(--danger); }

.login-wrap { max-width: 380px; margin: 80px auto; }
.login-wrap .card { padding: 28px; }
.login-wrap h1 { font-size: 20px; margin: 0 0 4px; text-align: center; }
.login-wrap .sub { text-align: center; color: var(--muted); margin-bottom: 20px; }

.wb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.case-steps { background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin: 6px 0; }
details.commit-detail summary { cursor: pointer; color: var(--primary); }

.desc-img {
  display: inline-block;
  max-width: 100%;
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 4px 0;
  vertical-align: top;
  cursor: zoom-in;
}

.desc-preview {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: -6px 0 12px;
  background: #fafbfc;
}
.desc-preview-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border-bottom: 1px dashed var(--border);
}
.desc-preview-content {
  padding: 8px 10px;
  min-height: 48px;
  white-space: pre-wrap;
  word-break: break-word;
}
.desc-preview-content .desc-preview-empty { color: #c0c6cf; }
