:root {
  --bg: #f5f7fb;
  --card: #fff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --pending: #9ca3af;
  --developing: #2563eb;
  --testing: #d97706;
  --done: #16a34a;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.container { max-width: 1280px; margin: 0 auto; padding: 20px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }
.pre { white-space: pre-wrap; word-break: break-word; }

.topbar {
  display: flex; align-items: center; gap: 8px 24px; flex-wrap: wrap;
  background: #111827; color: #fff; padding: 8px 20px; min-height: 52px;
  position: sticky; top: 0; z-index: 10;
}
.topbar[hidden] { display: none; }
.topbar .brand { color: #fff; font-weight: 600; font-size: 16px; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: #d1d5db; padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
.topbar nav a.active, .topbar nav a:hover { background: #374151; color: #fff; text-decoration: none; }
.topbar .me { display: flex; gap: 12px; align-items: center; color: #d1d5db; white-space: nowrap; }
@media (max-width: 760px) {
  .topbar .me .small { display: none; }
  .container { padding: 12px; }
}

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); padding: 6px 14px; border-radius: 6px; cursor: pointer; font: inherit;
}
.btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.sm { padding: 2px 8px; font-size: 12px; }
.btn.link { border: none; background: none; color: var(--primary); padding: 0; }

input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: 6px 10px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; color: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
textarea { min-height: 100px; resize: vertical; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-weight: 500; margin-bottom: 4px; }
.field .req::after { content: " *"; color: var(--danger); }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.field .err, .err-text { color: var(--danger); font-size: 12px; margin-top: 4px; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--danger); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.inline-opts { display: flex; gap: 16px; flex-wrap: wrap; }
.inline-opts label { display: inline-flex; align-items: center; gap: 4px; font-weight: normal; cursor: pointer; }

table.table { width: 100%; border-collapse: collapse; background: #fff; min-width: 900px; }
.table td.title-cell { min-width: 220px; }
.table .nowrap { white-space: nowrap; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; background: #f9fafb; white-space: nowrap; }
.table tr:hover td { background: #fafafa; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table tr.overdue td:first-child { box-shadow: inset 3px 0 0 var(--danger); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; line-height: 20px;
  background: #f3f4f6; color: #374151; white-space: nowrap;
}
.badge.st-pending { background: #f3f4f6; color: #4b5563; }
.badge.st-developing, .badge.st-in_progress { background: #dbeafe; color: #1e40af; }
.badge.st-testing { background: #fef3c7; color: #92400e; }
.badge.st-done { background: #dcfce7; color: #166534; }
.badge.overdue { background: var(--danger); color: #fff; font-weight: 600; }
.badge.warn { background: #fee2e2; color: #991b1b; }
.badge.type-bug { background: #fee2e2; color: #991b1b; }
.badge.type-optimize { background: #e0e7ff; color: #3730a3; }
.badge.type-feature { background: #d1fae5; color: #065f46; }
.badge.pr-highest { background: #7f1d1d; color: #fff; }
.badge.pr-high { background: #fecaca; color: #7f1d1d; }
.badge.pr-medium { background: #fde68a; color: #78350f; }
.badge.pr-medium_low { background: #e0f2fe; color: #075985; }
.badge.pr-low { background: #f3f4f6; color: #4b5563; }
.badge.acct { background: #ede9fe; color: #5b21b6; }
.badge.tag { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }

.progress { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #f3f4f6; min-width: 120px; }
.progress span { display: block; height: 100%; }
.progress .p-pending { background: var(--pending); }
.progress .p-developing { background: var(--developing); }
.progress .p-testing { background: var(--testing); }
.progress .p-done { background: var(--done); }
.counts { display: flex; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.counts i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; }

.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; border: 1px solid; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.toast { background: #111827; color: #fff; padding: 10px 16px; border-radius: 6px; max-width: 420px; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

dialog.modal { border: none; border-radius: 10px; padding: 0; width: min(860px, 94vw); max-height: 90vh; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
dialog.modal::backdrop { background: rgba(17,24,39,.5); }
.modal-head { display: flex; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; flex: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; max-height: calc(90vh - 120px); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

.picker { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: #fafafa; }
.picker-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
@media (max-width: 760px) { .picker-cols { grid-template-columns: 1fr; } }
.list-box { border: 1px solid var(--border); background: #fff; border-radius: 6px; max-height: 260px; overflow-y: auto; }
.list-box .item { padding: 6px 10px; border-bottom: 1px solid #f3f4f6; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.list-box .item:hover { background: #eff6ff; }
.list-box .item.active { background: #dbeafe; }
.list-box .item.disabled { color: var(--muted); cursor: default; }
.list-box .empty { padding: 12px; color: var(--muted); text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #c7d2fe; border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12px; }
.chip button { border: none; background: #eef2ff; border-radius: 50%; width: 18px; height: 18px; cursor: pointer; line-height: 1; }

.uploader .files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.file-tile { width: 140px; border: 1px solid var(--border); border-radius: 6px; padding: 6px; background: #fff; font-size: 12px; }
.file-tile img { width: 100%; height: 90px; object-fit: cover; border-radius: 4px; background: #f3f4f6; display: block; }
.file-tile .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-tile.failed { border-color: #fecaca; background: #fef2f2; }
.file-tile .bar { height: 4px; background: #e5e7eb; border-radius: 2px; overflow: hidden; margin: 4px 0; }
.file-tile .bar span { display: block; height: 100%; background: var(--primary); }

.gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery a.thumb { display: block; width: 120px; height: 90px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: #f3f4f6; }
.gallery a.thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery .g-item { text-align: center; font-size: 12px; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 24px; }
.info-grid .k { color: var(--muted); font-size: 12px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 14px 12px; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; }
.timeline li.reject::before { background: var(--danger); }
.timeline li.pass::before { background: var(--success); }

.branch-sec { border: 1px solid var(--border); border-radius: 6px; padding: 12px; margin-bottom: 12px; }
.branch-sec.has-err { border-color: var(--danger); }
.login-wrap { max-width: 380px; margin: 10vh auto; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.diff { font-size: 12px; color: var(--muted); }
.diff del { color: #991b1b; }
.diff ins { color: #166534; text-decoration: none; }
