:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --text: #1d2433;
  --muted: #657085;
  --line: #d9deea;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --teal: #0f766e;
  --amber: #b45309;
  --red: #b91c1c;
  --green: #166534;
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel);
  cursor: pointer;
}

button:hover {
  border-color: #aab4c5;
  background: #f9fafb;
}

button.primary {
  border-color: var(--blue);
  color: #fff;
  background: var(--blue);
}

button.primary:hover {
  border-color: var(--blue-dark);
  background: var(--blue-dark);
}

button.danger {
  border-color: #fecaca;
  color: var(--red);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 180px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 248, 251, 0.96);
  backdrop-filter: blur(10px);
}

.app-header h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.header-actions,
.pane-toolbar,
.row-actions,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.4fr);
  grid-template-rows: auto minmax(0, calc(100vh - 154px));
  gap: 14px;
  padding: 14px;
}

.summary-band {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
}

.metric {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.list-pane,
.detail-pane {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.list-pane {
  display: flex;
  flex-direction: column;
}

.pane-toolbar {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.pane-toolbar select {
  width: 132px;
}

.listing-list {
  overflow: auto;
}

.listing-row {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid #edf0f6;
  border-radius: 0;
  text-align: left;
  background: transparent;
}

.listing-row:hover,
.listing-row.active {
  background: #eef4ff;
}

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 38px;
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  background: var(--teal);
}

.score.warn {
  background: var(--amber);
}

.score.bad {
  background: var(--red);
}

.listing-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.listing-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  color: #314055;
  background: #eef1f6;
  font-size: 12px;
  font-weight: 700;
}

.pill.high {
  color: var(--red);
  background: #fee2e2;
}

.pill.medium {
  color: var(--amber);
  background: #fef3c7;
}

.pill.low {
  color: var(--teal);
  background: #ccfbf1;
}

.detail-pane {
  overflow: auto;
}

.status-line {
  min-height: 38px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.detail {
  padding: 14px;
}

.detail h2 {
  margin: 0;
  font-size: 22px;
}

.detail h3 {
  margin: 20px 0 8px;
  font-size: 15px;
}

.detail-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: start;
}

.detail-links {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.detail-links a {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--blue);
  text-decoration: none;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.score-cell {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

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

.score-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.issue-list,
.tag-list,
.image-list,
.notes-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.issue-item,
.image-item,
.note-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfe;
}

.issue-head,
.image-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.issue-id {
  font-weight: 800;
}

.issue-item p,
.note-item p {
  margin: 4px 0 0;
}

.tag-list {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.tag-list li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #fbfcfe;
  font-size: 12px;
}

.image-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 10px;
}

.image-item img {
  width: 92px;
  height: 92px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef1f6;
}

.image-controls {
  display: grid;
  gap: 8px;
}

.confirm-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.patch-section {
  display: grid;
  gap: 8px;
}

.empty-state {
  max-width: 480px;
  margin: 80px auto;
  color: var(--muted);
  text-align: center;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef1f6;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 18px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

@media (max-width: 960px) {
  .app-header,
  .detail-header,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }

  .summary-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-pane,
  .detail-pane {
    max-height: none;
  }

  .score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .image-item,
  .confirm-row {
    grid-template-columns: 1fr;
  }
}
