.projects-page {
  background: var(--bg);
}

.projects-shell {
  margin: 0 auto;
  max-width: 1520px;
  min-height: 100vh;
  padding: 24px;
}

.projects-topbar,
.projects-topbar-actions,
.project-toolbar-actions,
.project-detail-title-row,
.project-form-actions,
.project-detail-header-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

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

.projects-topbar {
  flex-wrap: wrap;
  justify-content: space-between;
  margin-bottom: 16px;
}

.projects-topbar-actions {
  flex-wrap: wrap;
}

.project-status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-bottom: 16px;
}

.project-status-grid article {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 92px;
  padding: 14px;
}

.project-status-grid span,
.project-status-grid strong {
  display: block;
}

.project-status-grid span,
.project-list-panel .panel-header span,
.project-detail-header p,
.project-detail-header > span,
.project-form label > span,
.project-action-form label > span {
  color: var(--muted);
  font-size: 12px;
}

.project-status-grid strong {
  font-size: 21px;
  margin-top: 10px;
}

.project-toolbar {
  margin-bottom: 16px;
  padding: 14px 16px 10px;
}

.project-filter-form {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(200px, 1fr) minmax(140px, 190px) minmax(140px, 190px) minmax(160px, 210px) auto;
}

.project-filter-form label,
.project-form label,
.project-action-form label {
  display: grid;
  gap: 6px;
}

.project-feedback {
  color: var(--blue-dark);
  font-size: 13px;
  min-height: 19px;
  padding-top: 8px;
}

.project-edit-status {
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}

.project-create-panel {
  margin-bottom: 16px;
}

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

.project-create-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 18px;
}

.project-form-wide {
  grid-column: 1 / -1;
}

.project-workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
}

.project-list-panel {
  align-self: start;
  overflow: hidden;
  position: sticky;
  top: 16px;
}

.project-list {
  display: grid;
  max-height: calc(100vh - 190px);
  overflow-y: auto;
}

.project-list-item {
  background: var(--surface);
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  text-align: left;
  width: 100%;
}

.project-list-item:last-child {
  border-bottom: 0;
}

.project-list-item:hover,
.project-list-item.selected {
  background: #eef5fa;
}

.project-list-item.selected {
  box-shadow: inset 3px 0 0 var(--blue);
}

.project-list-title,
.project-list-meta,
.project-list-footer {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.project-attention-marker {
  color: var(--red);
  font-weight: 700;
}

.project-list-title strong {
  font-size: 14px;
  line-height: 1.4;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.project-status-badge,
.project-priority-badge {
  border-radius: 999px;
  display: inline-flex;
  flex: none;
  font-size: 12px;
  padding: 4px 8px;
}

.project-status-badge {
  background: #e9f2f8;
  color: var(--blue-dark);
}

.project-status-badge.engineering_review,
.project-priority-badge.high {
  background: #fff3d8;
  color: var(--amber);
}

.project-status-badge.won {
  background: #e8f5ec;
  color: var(--green);
}

.project-status-badge.lost,
.project-priority-badge.urgent {
  background: #faeaea;
  color: var(--red);
}

.project-detail-panel {
  min-height: 640px;
  overflow: hidden;
}

.project-empty {
  color: var(--muted);
  padding: 80px 20px;
  text-align: center;
}

.project-detail-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 18px;
}

.project-detail-header h2 {
  font-size: 19px;
  overflow-wrap: anywhere;
}

.project-detail-header > div,
.project-detail-title-row {
  min-width: 0;
}

.project-detail-header p {
  margin-top: 7px;
  overflow-wrap: anywhere;
}

.project-detail-feedback {
  background: #eef5fa;
  border-bottom: 1px solid var(--line);
  color: var(--blue-dark);
  font-size: 13px;
  padding: 9px 18px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.project-detail-feedback:empty {
  display: none;
}

.project-detail-feedback.error {
  background: #fff5f5;
  color: var(--red);
}

.project-detail-section {
  border-top: 1px solid var(--line);
  padding: 18px;
}

.project-detail-header + .project-detail-section {
  border-top: 0;
}

.project-detail-section h3,
.project-action-form h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.project-collaboration-summary {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0;
}

.project-collaboration-summary > div {
  border-right: 1px solid var(--line);
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 16px 18px;
}

.project-collaboration-summary > div:last-child {
  border-right: 0;
}

.project-collaboration-summary span,
.project-collaboration-summary p,
.project-section-heading p,
.project-record-main > span,
.project-record-main > p {
  color: var(--muted);
  font-size: 12px;
}

.project-collaboration-summary strong {
  font-size: 18px;
}

.project-action-grid,
.project-evidence-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.project-action-form {
  border-top: 3px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.project-action-form button {
  justify-self: start;
}

.project-action-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  min-height: 18px;
}

.project-management-section {
  display: grid;
  gap: 14px;
}

.project-section-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.project-section-heading h3 {
  margin-bottom: 4px;
}

.project-inline-form {
  align-items: end;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(130px, 180px) minmax(160px, 1fr) minmax(180px, 1fr) auto;
  padding: 14px;
}

.project-inline-form label {
  display: grid;
  gap: 6px;
}

.project-inline-form label > span {
  color: var(--muted);
  font-size: 12px;
}

.project-attachment-form [hidden] {
  display: none;
}

.project-attachment-mode {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  display: inline-flex;
  gap: 3px;
  grid-column: 1 / -1;
  justify-self: start;
  padding: 3px;
}

.project-attachment-mode button {
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: var(--muted);
  min-height: 30px;
  padding: 5px 10px;
}

.project-attachment-mode button[aria-pressed="true"] {
  background: #e9f2f8;
  color: var(--blue-dark);
  font-weight: 700;
}

.project-attachment-policy {
  color: var(--muted);
  font-size: 12px;
  grid-column: 1 / -1;
  min-height: 18px;
}

.project-upload-progress {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
  padding: 12px 14px;
}

.project-upload-progress[hidden],
.project-upload-list:empty {
  display: none;
}

.project-upload-progress > div {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.project-upload-progress strong {
  font-size: 13px;
}

.project-upload-progress span,
.project-upload-main > span {
  color: var(--muted);
  font-size: 12px;
}

.project-upload-progress progress,
.project-upload-main progress {
  accent-color: var(--blue);
  height: 8px;
  width: 100%;
}

.project-upload-list {
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.project-upload-item {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-width: 0;
  padding: 11px 14px;
}

.project-upload-item:last-child {
  border-bottom: 0;
}

.project-upload-item[data-upload-status="failed"] {
  border-left: 3px solid var(--red);
}

.project-upload-item[data-upload-status="published"] {
  border-left: 3px solid var(--green);
}

.project-upload-main {
  display: grid;
  gap: 6px;
  min-width: 0;
  width: min(100%, 640px);
}

.project-inline-wide {
  grid-column: span 2;
}

.project-record-list {
  border: 1px solid var(--line);
  display: grid;
}

.project-record-item {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-width: 0;
  padding: 12px 14px;
}

.project-record-item:last-child {
  border-bottom: 0;
}

.project-record-item.closed,
.project-record-item.removed {
  background: var(--surface-soft);
  opacity: 0.72;
}

.project-record-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.project-record-title-row,
.project-record-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.project-record-title-row strong,
.project-record-reference {
  overflow-wrap: anywhere;
}

.project-record-badge {
  background: #e9f2f8;
  border-radius: 999px;
  color: var(--blue-dark);
  font-size: 11px;
  padding: 3px 7px;
}

.project-record-badge.overdue {
  background: #faeaea;
  color: var(--red);
}

.project-record-badge.due-soon {
  background: #fff3d8;
  color: var(--amber);
}

.project-record-badge.muted {
  background: var(--line);
  color: var(--muted);
}

.project-record-empty {
  color: var(--muted);
  font-size: 13px;
  padding: 16px;
}

.compact-button {
  flex: none;
  min-height: 34px;
  padding: 6px 10px;
}

.project-source {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.project-tag-list,
.project-risk-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.project-tag-list li,
.project-risk-list li {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 5px 8px;
}

.project-risk-list li {
  background: #fff5f5;
  border-color: #eccccc;
  color: var(--red);
}

.project-activity-list {
  display: grid;
  gap: 0;
}

.project-activity-item {
  border-left: 2px solid var(--line-strong);
  display: grid;
  gap: 5px;
  margin-left: 6px;
  padding: 0 0 16px 16px;
}

.project-activity-item:last-child {
  padding-bottom: 0;
}

.project-activity-item strong {
  font-size: 13px;
}

.project-activity-item span,
.project-activity-item p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (max-width: 1050px) {
  .project-filter-form,
  .project-create-form,
  .project-inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .project-toolbar-actions {
    grid-column: 1 / -1;
  }

  .project-inline-form button {
    justify-self: start;
  }

  .project-workspace {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .projects-shell {
    padding: 14px;
  }

  .projects-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .projects-topbar-actions {
    width: 100%;
  }

  .projects-topbar-actions a {
    flex: 1;
  }

  .project-status-grid,
  .project-action-grid,
  .project-evidence-grid,
  .project-workspace {
    grid-template-columns: 1fr;
  }

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

  .project-collaboration-summary {
    grid-template-columns: 1fr;
  }

  .project-collaboration-summary > div {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    min-height: 0;
  }

  .project-collaboration-summary > div:last-child {
    border-bottom: 0;
  }

  .project-list-panel {
    position: static;
  }

  .project-list {
    max-height: 420px;
  }
}

@media (max-width: 560px) {
  .projects-topbar-actions {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .projects-topbar-actions a {
    min-width: 0;
    white-space: nowrap;
    width: 100%;
  }

  .projects-topbar-actions a:last-child {
    grid-column: 1 / -1;
  }

  .project-filter-form,
  .project-create-form,
  .project-form,
  .project-inline-form {
    grid-template-columns: 1fr;
  }

  .project-status-grid article {
    min-height: 82px;
  }

  .project-inline-wide {
    grid-column: auto;
  }

  .project-attachment-mode,
  .project-attachment-policy {
    grid-column: 1;
  }

  .project-record-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .project-upload-item {
    align-items: stretch;
    flex-direction: column;
  }

  .project-toolbar-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .project-toolbar-actions button {
    padding-left: 8px;
    padding-right: 8px;
  }
}
