:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --line: #d9dee8;
  --brand: #176b87;
  --brand-strong: #0f4c5c;
  --accent: #d97706;
  --ok: #198754;
  --danger: #b42318;
  --shadow: 0 16px 42px rgba(31, 41, 55, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  margin-bottom: 14px;
}

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

.summary {
  min-width: 128px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  box-shadow: var(--shadow);
}

.entry-panel {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 18px;
  border: 0;
  border-radius: 0;
  background: rgba(17, 24, 39, 0.48);
}

.entry-panel[hidden] {
  display: none;
}

.bug-form,
.status-form {
  width: min(720px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
  padding: 16px;
}

.status-form {
  width: min(420px, 100%);
  grid-template-columns: 1fr;
}

.form-head,
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-head h2 {
  margin: 0;
  font-size: 20px;
}

.form-actions {
  justify-content: flex-end;
}

.status-target {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f3f6fa;
  color: var(--muted);
  line-height: 1.55;
  word-break: break-word;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.wide {
  grid-column: 1 / -1;
  min-width: 0;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select {
  height: 42px;
  padding: 0 10px;
}

textarea {
  min-height: 42px;
  resize: vertical;
  padding: 10px;
  line-height: 1.5;
}

select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.primary-btn,
.ghost-btn,
.icon-btn {
  height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
}

.primary-btn {
  min-width: 132px;
  align-self: end;
  background: var(--brand);
  color: #fff;
}

.primary-btn:hover {
  background: var(--brand-strong);
}

.ghost-btn {
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.icon-btn {
  width: 42px;
  background: #f3f4f6;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  border-color: var(--brand);
  background: #e9f5f8;
  color: var(--brand-strong);
  font-weight: 800;
}

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

.bug-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge {
  padding: 4px 8px;
  border-radius: 6px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.category {
  background: #fff3d7;
  color: #92400e;
}

.badge.status {
  background: #e8f3ff;
  color: #175cd3;
}

.badge.done {
  background: #e9f7ef;
  color: var(--ok);
}

.bug-id {
  color: var(--muted);
  font-size: 13px;
}

.description {
  margin: 0;
  line-height: 1.65;
  white-space: pre-wrap;
}

.plan {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: #fff8ed;
  color: #4b5563;
  line-height: 1.6;
  white-space: pre-wrap;
}

.card-actions {
  display: grid;
  grid-template-columns: auto;
  gap: 8px;
  align-items: center;
  justify-content: start;
}

.small-btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

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

.empty {
  display: none;
  margin: 40px 0 0;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  display: none;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .bug-form,
  .bug-grid {
    grid-template-columns: 1fr;
  }

  .card-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 24px, 1180px);
    padding-top: 18px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
  }

  .top-actions .primary-btn {
    min-width: 136px;
  }

  .summary {
    text-align: left;
    box-shadow: none;
  }

  .entry-panel {
    align-items: end;
    padding: 12px;
  }

  .bug-form,
  .status-form {
    grid-template-columns: 1fr;
    max-height: min(86vh, 720px);
  }

  .small-btn {
    width: 100%;
    min-width: 96px;
  }
}
